Ask Your Question

present sage output as "normal" mathematics

asked 2015-11-22 16:47:51 -0600

Yorgos gravatar image

updated 2015-11-23 17:35:25 -0600

vdelecroix gravatar image


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

f=x^2-3*y; f

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

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-11-29 14:20:48 -0600

A.P. gravatar image

updated 2015-11-29 15:15:54 -0600

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


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

edit flag offensive delete link more

answered 2015-11-23 17:39:48 -0600

vdelecroix gravatar image

updated 2015-11-25 10:35:32 -0600

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
edit flag offensive delete link more

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


Asked: 2015-11-22 16:47:51 -0600

Seen: 365 times

Last updated: Nov 29 '15