Ask Your Question
0

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

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

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

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

 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

edit flag offensive delete link more
1

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

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

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

Stats

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

Seen: 178 times

Last updated: Nov 29 '15