I have the following function $f(x)=\|x-a\|^2+\sum_{i=0}^{n-1}\sqrt{(x_{i+1}-x_i)^2+b}$ where $a$ is a n-vector and $b$ scalar.
I need to find the gradient and the Hessian of $f(x)$.
I am guessing that i need to expand $\|x-a\|^2=(x-a)^T(x-a)=x^Tx-x^Ta-a^Tx-a^Ta$ first. Now I want to use the property of quadratic function where if $f(x)=x^TPx+q^Tx+p => \nabla f(x)=2Px+q$ and $\nabla ^2 f(x)=2P$
I do not know if I am on the right path, but it seams like I cannot figure out what $P$ is. Maybe there is another way of finding gradient and the Hessian of f(x)?
Thanks