Calculate the directional derivative for the function
$$f(x) = \sum_{i=1}^{n-1} |x_{i+1} - x_i|$$
where $\textbf{x}=(x_1,...,x_n)^T$, with $n \geq 2$ for any vector $\textbf{v}=(v_1,...,v_n)^T$.
What I thought was, we might have to erase the absolute value first. Without absolute values some terms could be easily eliminated. But don't know how to achieve such goal. Could anyone shed light on it?
You can use the limit definition of the directional derivative.
$$\nabla_\mathbf{v}f(\mathbf{x})=\lim_{h\to0}\frac{f(\mathbf{x}+h\mathbf{v})-f(\mathbf{x})}{h}$$
$$=\lim_{h\to0}\frac{\sum_{i=1}^{n-1}|(x_{i+1}+hv_{i+1})-(x_i+hv_i)|-\sum_{i=1}^{n-1}|x_{i+1}-x_i|}{h}$$
$$=\lim_{h\to0}\frac{\sum_{i=1}^{n-1}|(x_{i+1}-x_i)+h(v_{i+1}-v_i)|-|x_{i+1}-x_i|}{h}$$
Here we can use the fact that $|a|>|b|\implies|a+b|=|a|+b\ sgn(a)$, where sgn signifies the sign function. This will only work when $x_{i+1}-x_i\neq0$.
$$=\sum_{i=1}^{n-1}(v_{i+1}-v_i)sgn(x_{i+1}-x_i)$$
The limit will not converge to this sum if and only if there is at least one $i$ such that $x_{i+1}-x_i=0$ and $v_{i+1}-v{i}\neq 0$. If such an i exists, there will be a term $|v_{i+1}-v_i|\frac{|h|}{h}$, which does not have a limit as $h\to 0$.