Ask Your Question
0

present sage output as "normal" mathematics

asked 2015-11-22 23:47:51 +0100

Yorgos gravatar image

updated 2015-11-24 00:35:25 +0100

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-11-24 00:39:48 +0100

vdelecroix gravatar image

updated 2015-11-25 17:35:32 +0100

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
1

answered 2015-11-29 21:20:48 +0100

A.P. gravatar image

updated 2015-11-29 22:15:54 +0100

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

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 23:47:51 +0100

Seen: 748 times

Last updated: Nov 29 '15