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 ?

In principle, one could recognize this by taking the antiderivative of expr and recognizing the form you mention. However, the maxima backend that is used by default does not recognize this. Note that

`diff(J**2/rho, x)`

returns the expression in the form`expr`

, so`expr`

is considered the "simplified" form in that sense (it's certainly closer to a general standard form than the other). "compact for a human" is not always "best for computation".