Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

WorksForMe(TM) :

sage: rho=function("rho")(x)
sage: J=function("J")(x)
sage: rho.diff(x)
diff(rho(x), x)
sage: (J**2/rho**2).diff(x).factor()
2*(rho(x)*diff(J(x), x) - J(x)*diff(rho(x), x))*J(x)/rho(x)^3

I. e. $$\frac{2 {\left(\rho\left(x\right) \frac{\partial}{\partial x}J\left(x\right) - J\left(x\right) \frac{\partial}{\partial x}\rho\left(x\right)\right)} J\left(x\right)}{\rho\left(x\right)^{3}}$$.

If you are dead set to use a "function call" syntax, it works, too :

sage: factor(diff(J**2/rho**2,x))
2*(rho(x)*diff(J(x), x) - J(x)*diff(rho(x), x))*J(x)/rho(x)^3

or even :

sage: factor(derivative(J**2/rho**2))
2*(rho(x)*diff(J(x), x) - J(x)*diff(rho(x), x))*J(x)/rho(x)^3

So where's your beef ? Oh, I see :

sage: Derivative(J**2/rho**2,x)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-18-221717693903> in <module>()
----> 1 Derivative(J**Integer(2)/rho**Integer(2),x)

NameError: name 'Derivative' is not defined

So what ?