ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 28 Oct 2015 22:34:28 -0500derivative of order var('m') returns 0http://ask.sagemath.org/question/30330/derivative-of-order-varm-returns-0/ Hello,
In mathematica I can differentiate a function m times with respect to x, where m doesn't have an explicit value yet and get an expression that can be evaluated as below:
<pre>
#MATHMATICA CODE
in[0] g = x^2 + 3/2*(x^2 - 1)*x
f = D[g, {x, m}]
out[0]= ∂(x,m)(3/2x(-1+x^2))+Power(m,0)[x,2]
in[1] f /. {m -> 2}
out[1]= 2+9x
</pre>
What I believe to be the equivalent code in sage will only give me 0 instead of an expression which I could then evaluate by setting m=2:
<pre>
#Sage example 1
sage: g = x^2 + 3/2*(x^2 - 1)*x
sage: var('m')
sage: diff(g,x,m)
0
</pre>
I know it is possible to differentiate a variable number of times due to the following:
<pre>
#Sage example 2
sage: diff((x^2-1)^n,x,n)
2*(x^2 - 1)^(n - 1)*n*x*log(x^2 - 1) + 2*(x^2 - 1)^(n - 1)*x
</pre>
I think that example 2 works because I have x raised to the power n.
Is it possible to accomplish the equivalent of what I did in mathematica in sage (i.e. have example 1 not return 0)?
Alternatively if this is not possible what advice do you have for how I could work on making this functionality exist?
Thanks in advance.
ianhiWed, 28 Oct 2015 22:34:28 -0500http://ask.sagemath.org/question/30330/