Ask Your Question

Forcing Prime Notation

asked 2012-11-25 17:19:07 -0600

hwong557 gravatar image

I want sage to implicitly differentiate a function for me, say

d/dx f(x)^2 = 2f(x)* f'(x).

I can do this by entering:

f=function('f', x)

This returns

2 f(x) D[0] (f) (x)

which is correct, but hard for me to read. Can I make sage return:

2 f(x) f'(x)


edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2012-11-25 20:18:01 -0600

achrzesz gravatar image

updated 2012-11-26 03:30:44 -0600

kcrisman gravatar image

This is easy to read:

sage: maxima('diff(f(x)^2,x)')                 


sage: from sympy import *                      
sage: x=Symbol('x')      
sage: f=Function('f')    
sage: diff(f(x)^2,x)     
2*f(x)*Derivative(f(x), x)


sage: maxima_console()
(%i1) derivabbrev:true;
(%o1)                                true
(%i2) diff(f(x)^2,x);
(%o2)                            2 f(x) f(x)
edit flag offensive delete link more

answered 2012-11-26 00:09:20 -0600

You can try the patch attached to issue #6344. It is more than 3 years old, so some work might be needed to make it apply to a recent Sage version, but it essentially does exactly what you need. See this comment for some examples.

edit flag offensive delete link more


"However, I think we should settle on an output style ASAP, without letting too many releases go by." Oops. Perhaps this is still worth changing? Would we need deprecation?

kcrisman gravatar imagekcrisman ( 2012-11-26 03:30:06 -0600 )edit

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: 2012-11-25 17:19:07 -0600

Seen: 124 times

Last updated: Nov 26 '12