Maxima CAS: How to differentiate w.r.t. an expression?
Is there a way to differentiate with respect to an expression, instead of a single variable in Maxima CAS? Here is a toy example, which should give $\frac{\partial}{\partial x^2}x^2=1$:
diff(x^2,x^2);
with an error in wxMaxima 20.06.6
diff: second argument must be a variable; found x^2
For clarity, I meant first derivative with respect to an expression of $x$, not a second derivative with respect to $x$ itself. Note that the latter gives $\frac{\partial^2}{\partial x^2}x^2=2\ne 1$ and can be easily computed as diff(x^2,x,2)
Solution 1:
Just apply the chain rule in the CAS
$$\frac{df(x)}{dg(x)}=\frac{\frac{df(x)}{dx}}{\frac{dg(x)}{dx}}$$
Just define $g(x)$ and apply.