# Taking a derivative of a magnitude of a vector

I have found several questions including this as a step in the explanation, but have not been able to find an explicit explanation of how to take a derivative of a magnitude of a vector.

I am trying to take the derivative d/dt ||r'(t)|| but don't know how to address the magnitude signs.

• Do you have a formula for $r(t)$ and for $r'(t)$? If so get the formula for $||r'(t)||$ which will be a 1-var function of $t,$ then do derivative of that. Commented Jan 4, 2019 at 21:34
• What is your norm? The one derived from the dot product? Commented Jan 4, 2019 at 21:36
• @mathcounterexamples.net r(t) is a path -- what would the norm derived from the dot product be? Commented Jan 4, 2019 at 21:44
• If you, like me, came here trying to do machine learning square loss like minimizing $||y-Xw||$^2 by differentiating and setting equal to 0, I don't recommend trying the solutions here. Instead, just use the dot product definition of magnitude to get to $(y-Xw)^T(y-Xw)$, do out the multiplication and then use (84) of the Matrix Cookbook. A tutorial is here Commented Sep 14, 2022 at 1:36

I will assume that you are working with the euclidian norm and the dot product. Let $$v(t)$$ be a vector: $$v(t) \cdot v(t)=|v(t)|^2$$ And $$\frac{\mathrm{d}|v(t)|^2}{\mathrm{d}t}=2|v(t)|\frac{\mathrm{d}|v(t)|}{\mathrm{d}t}$$ Which implies that \begin{align} \frac{\mathrm{d}|v(t)|}{\mathrm{d}t}&=\frac{1}{2|v(t)|}\frac{\mathrm{d}|v(t)|^2}{\mathrm{d}t}\\ &=\frac{1}{2|v(t)|}\frac{\mathrm{d}(v(t) \cdot v(t))}{\mathrm{d}t}\\ &=\frac{1}{2|v(t)|}\left(v(t) \cdot v'(t)+v'(t) \cdot v(t)\right)\\ &=\frac{1}{2|v(t)|}\left(2v(t) \cdot v'(t)\right)\\ &=\frac{v(t) \cdot v'(t)}{|v(t)|} \end{align}
• (If anyone is unfamiliar with the notation, $v^\prime(t) = \dot{v}(t) = \frac{d v(t)}{d t}$.) Commented Jan 5, 2019 at 16:12
If the norm is derived from the dot product $$\langle \cdot , \cdot \rangle$$, then
$$\frac{d\Vert r^\prime(t) \Vert}{dt} = \frac{\langle r^\prime(t),r^{\prime \prime}(t)\rangle}{\Vert r^\prime(t)\Vert}.$$
• Using the chain rule. A more simple way is to use the coordinates and the fact that for a vector $x=(x_1, \dots, x_n)$ (in dimension $n$), you have $\Vert x \Vert = \sqrt{x_1^2 + \dots +x_n^2}$ Commented Jan 4, 2019 at 21:56
\eqalign{ & \left| {r(t)} \right|^2 = r_{\,x} (t)^2 + r_{\,y} (t)^2 + \cdots \cr & 2\left| {r(t)} \right|{d \over {dt}}\left| {r(t)} \right| = 2\left( {r_{\,x} (t)r_{\,x} '(t) + r_{\,y} (t)r_{\,y} '(t) + \cdots } \right) \cr & {d \over {dt}}\left| {r(t)} \right| = {{r_{\,x} (t)r_{\,x} '(t) + r_{\,y} (t)r_{\,y} '(t) + \cdots } \over {\left| {r(t)} \right|}} \cr}