# How to compute the derivative of the magnitude of a vector? [duplicate]

Mathematically we can say the following

$$\frac{d}{d\vec{x}}\frac{1}{|\vec{x}|} = -\frac{\vec{x}}{|\vec{x}|^3}.$$

However, in Mathematica, I perform the following D[Abs[x]^(-1), x] which outputs -Abs'[x]/Abs[x]^2.

Any suggestions?

• what you mean deriving scalar by vector? The closest assumption i can think about is d F[x]/d x = Grad[F, x], x={x1,x2,...,xn} – k_v Jul 7 '17 at 9:33
• It's one of the examples of the help page for Grad. – b.gates.you.know.what Jul 7 '17 at 10:16

Quiet[xx = Table[x[[i]], {i, 1, 3}]];

Remark: The length of a vector in Mathematica is obtained by Norm[x]. Abs operates on each entry, thus Abs[x] is the vector of moduli.