Ask Your Question
1

Forcing Prime Notation

asked 2012-11-26 00:19:07 +0200

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:

var('x')
f=function('f', x)
(f^2).diff(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)

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-11-26 07:09:20 +0200

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

Comments

"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 10:30:06 +0200 )edit
1

answered 2012-11-26 03:18:01 +0200

achrzesz gravatar image

updated 2012-11-26 10:30:44 +0200

kcrisman gravatar image

This is easy to read:

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
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: 2012-11-26 00:19:07 +0200

Seen: 425 times

Last updated: Nov 26 '12