# Cross check for the derivative of a unit vector $\frac{x}{|x|}$

Can you please help me in finding out the mistakes I am doing during the calculation of derivative of a vector. I am briefing the problem I am trying to solve as follows.

There is a line joining two points (1) and (3) as shown in the image below. The possible degrees of freedom at each of the points are shown as $$d_{1,1}$$, $$d_{1,2}$$ of point (1) in x- and y- directions. It is similar for point (3) as well.

The vector at the original configuration is calculated as,

$$V_{130}$$ = $$X_{30}$$ - $$X_{10}$$

The new orientation of the vector $$v_{13}$$ due to these displacement is $$v_{13} = V_{130}+d_{3}-d_{1}$$

And the unit vector $$c_{13} = \dfrac{v_{13}}{\det{v_{13}}}$$

Now, I am trying to calculate the derivative of the unit vector as follows

$$\dfrac{\partial{c_{13}}}{\partial{d_{i,n}}}$$ = $$\dfrac{\partial}{\partial{d_{i,n}}}$$ $$(\frac{v_{13} }{\det{v_{13} } })$$

where, i is the point number (1 or 3) and n is the component number (1 or 2).

$$\dfrac{\partial{c_{13}}}{\partial{d_{i,n}}}$$ = $$\dfrac{ \det{v_{13} \dfrac{\partial{v_{13}}}{\partial{d_{i,n}}}} - v_{13} \dfrac{v_{13}^{T}}{\det{v_{13}}} \dfrac{\partial{v_{13}}}{\partial{d_{i,n}}} } {\det{v_{13}}^2}$$

= $$\dfrac{ \left[ I - \dfrac{v_{13}}{\det{v_{13}}} \dfrac{v_{13}^{T}}{\det{v_{13}}} \right] } {\det{v_{13}}^2} \det{v_{13}} \dfrac{\partial{v_{13}}}{\partial{d_{i,n}}}$$

= $$\dfrac{ \left[ I - c_{13} c_{13}^{T} \right] } {\det{v_{13}}} \dfrac{\partial{v_{13}}}{\partial{d_{i,n}}}$$

= $$\dfrac{ \left[ I - c_{13} c_{13}^{T} \right] } {\det{v_{13}}} (\delta_{3i}-\delta_{1i}) \left[ \begin{array}{1} \delta_{1n} \\ \delta_{2n} \end{array} \right]$$

The above delta is Kronecker delta.

Can you please correct the above outcome of derivative?

Cross-Checking: When I am trying to cross check if the above derivative is correct, I am finding a discrepancy as shown below.

There is a line with coordinates $$X_{10} = (-1,-1)$$ and $$X_{30} = (1,1)$$ at its original configuration as shown in the image

The vector at the original configuration is calculated as,

$$V_{130}$$ = $$X_{30}$$ - $$X_{10}$$ = $$\left[\begin{array}{l}2\\2\end{array}\right]$$

The displacement of the points 1 and 3 are (new coordinate - old coordinate),

$$d_1$$ = $$\left[\begin{array}{l}1\\ -\sqrt(2)+1 \end{array}\right]$$ $$d_3$$ = $$\left[\begin{array}{l}-1\\ \sqrt(2)-1 \end{array}\right]$$

$$v_{13} = V_{130}+d_3-d_1 = \left[\begin{array}{l}0\\ 2\sqrt(2) \end{array}\right]$$

And the unit vector $$c_{13} = \dfrac{v_{13}}{\det{v_{13}}}$$ = $$\left[\begin{array}{l}0\\ 1 \end{array}\right]$$

Upon substitution in the above derivation formula,

$$\dfrac{\partial{c_{13}}}{\partial{d_{1,1}}} = \dfrac{1}{2\sqrt{2}} \left[ I - \left[ \begin{array}{3} 0 & 0 \\ 0 & 1 \\ \end{array} \right] \right] (-1) \left[ \begin{array}{1} 1 \\ 0 \\ \end{array} \right]$$

= $$\dfrac{-1}{2\sqrt{2}} \left[ \begin{array}{1} 1 \\ 0 \\ \end{array} \right]$$; $$\dfrac{\partial{c_{13}}}{\partial{d_{1,2}}} = 0$$

$$\dfrac{\partial{c_{13}}}{\partial{d_{3,1}}} = \dfrac{1}{2\sqrt{2}} \left[ \begin{array}{1} 1\\ 0 \\ \end{array} \right]$$; $$\dfrac{\partial{c_{13}}}{\partial{d_{3,2}}} = 0$$

Upon rearranging,

$$\dfrac{\partial{c_{13}^{1}}}{\partial{d_{1,n}}} = \dfrac{-1}{2\sqrt{2}} \left[\begin{array}{1}1\\0 \end{array}\right]$$; $$\dfrac{\partial{c_{13}^{1}}}{\partial{d_{3,n}}} = \dfrac{1}{2\sqrt{2}} \left[\begin{array}{1}1\\0 \end{array}\right]$$

By using chain rule of differentiation, $$c^{1}_{13} = \dfrac{\partial{c^{1}_{13}}}{\partial{d_{1,n}}} \ d_{1,n} + \dfrac{\partial{c^{1}_{13}}}{\partial{d_{3,n}}} \ d_{3,n}$$

$$c_{13}^{1}$$ = $$\frac{-1}{2\sqrt{2}} \left[\begin{array}{1} 1 & 0 \end{array} \right] * \left[\begin{array}{1} 1 \\ -\sqrt(2)+1 \end{array} \right] + \dfrac{1}{2\sqrt{2}} \left[\begin{array}{1} 1 & 0 \end{array} \right] * \left[\begin{array}{1} -1 \\ \sqrt(2)-1 \end{array} \right] = \frac{-1}{\sqrt{2}}$$;

$$c_{13}^{2}$$ =0

(WHICH IS NOT CORRECT). Can you please help me in which part of the calculation went wrong. Please let me know if you need any clarifications in the whole, I can re-explain to make you understand.

• Incomprehensible. What are the supposed variables $d_{i,n}$? Components of the constant vectors $d_i$???? The formula $\dfrac{\partial{c_{13}}}{\partial{d_{i,n}}} = \dfrac{\partial}{\partial{d_{i,n}}}$ has a typo? Commented Apr 2, 2019 at 8:10
• To address the question in the title: the derivative of $f(x)=x/|x|$ at a point $v$ is $D_xf(v)=-v/|x|^2$. Commented Apr 2, 2019 at 14:48
• Thank you @Martín-BlasPérezPinilla, I have corrected based on your comments. Commented Apr 2, 2019 at 18:05
• Thank you @MichaelHoppe, Can you please comment on the derivation in the description as well. Thanks in advance. Commented Apr 2, 2019 at 18:07
• Just to make sure that we are understanding: you want to calculate the derivative of the function $f\colon {\mathbb R}^2 \setminus \{0\} \to {\mathbb R}^2\setminus \{0\}$, given by $$f ( x ) = x / |x|.$$ Namely, $f$ takes vectors to unit vectors (vectors of length one). Correct? Commented Apr 3, 2019 at 2:01