I just wonder how can I do (step by step) partially differentiating $\displaystyle g_u(\vec x)$ with $\displaystyle \vec x$ where $\displaystyle \vec x = \vec 0$

Noted:

- The displacement of node u is depicted as in the attached picture.
- $\displaystyle \vec r_e$ denotes the vector in the local coordinate of u that starts from u and ens at the tip of the arc e
- $\displaystyle r_0$ is a constant value.
- E(u) is a set of arc e which is attached to node u

$\displaystyle g_u(\vec x)=\sum_{e\in E(u)}\left | \vec r_e - \vec x - r_0\frac{\vec r_e - \vec x}{\| \vec r_e - \vec x\|}\right |$

Actually, I already have the answer but I want to know step by step in solving this equation. Please help. Thank you in advance.

The answer is $\displaystyle \nabla g_u(\vec 0) = \sum_{e\in E(u)} \left ( 1 - \frac{\vec r_0}{\| \vec r_e \|}\right )\frac{\vec r_0}{\| \vec r_e \|}$