First time here? Check out the FAQ!

Ask Your Question
0

present sage output as "normal" mathematics

asked 9 years ago

Yorgos gravatar image

updated 9 years ago

vdelecroix gravatar image

Hello,

I am new to sage and I have the following question. Here is a minimal working example:

x,y=var('x,y')
f=x^2-3*y; f
f.diff(x)
g=f.diff(x);g

The output of it is 2*x, but I wonder if there is a way to say to sage that I want to present the output g=2x.

Thanks in advance

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 9 years ago

vdelecroix gravatar image

updated 9 years ago

slelievre gravatar image

Short answer: yes with

print "g = %r" % g

Other short answer: no, you cannot (easily) do that automatically.

Note that you can define g as a symbolic function

sage: g(x,y) = f.diff(x)
sage: g
(x, y) |--> 2*x
Preview: (hide)
link
1

answered 9 years ago

A.P. gravatar image

updated 9 years ago

If you're working from the notebook you can use the pretty_print function. In your example

 pretty_print(g)

will display 2x as rendered LaTeX. I doesn't just typeset mathematics, either: you can also use it to prettify other objects, like long lists or dictionaries. Here's a more interesting example

pretty print the derivative of a function involving tangents and fractions

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 9 years ago

Seen: 766 times

Last updated: Nov 29 '15