Can Mathematica generate symbolic expressions for gradients?
For example, if $x_1$ and $x_2$ are two points, could I get Mathematica to generate expressions similar to the following?
$\frac{\partial \left|x_1 - x_2\right|}{\partial x_1} = \frac{x_1 - x_2}{\left|x_1 - x_2\right|}$
$\frac{\partial \left|x_1 - x_2\right|}{\partial x_2} = \frac{x_2 - x_1}{\left|x_1 - x_2\right|}$
My experience with Mathematica is limited. I know how to get derivatives w.r.t. scalars.
Elsewhere on this site I found this question and from the answers it looks like Mathematica recently acquired the ability to do some amount of symbolic linear algebra.
D[Sqrt[(x1 - x2) (x1 - x2)], x1]
? Ifx1
andx2
are supposed to be vectors, then I think your expressions are wrong, because the left-hand-side is a scalar, and the right-hand side is a vector. $\endgroup$