# Forcing Prime Notation

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:

var('x')
f=function('f', x)
(f^2).diff(x)


This returns

2 f(x) D (f) (x)


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

2 f(x) f'(x)


Thanks.

edit retag close merge delete

Sort by » oldest newest most voted

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.

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?

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


And

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)


Also:

sage: maxima_console()
(%i1) derivabbrev:true;
(%o1)                                true
(%i2) diff(f(x)^2,x);
(%o2)                            2 f(x) f(x)
x

more