Given $n$ points in space, $p_1,p_2, \cdots , p_n$, find the point $p$ for which $f(p) = \sum_{i=1}^n |p-p_j|^2$.
I have the following in my notes:
(1) $f(p) = \sum_{i=1}^n |p-p_i|^2 = \sum_{i=1}^n (p-p_i)\cdot(p-p_i)$
=$\sum_{i=1}^n p \cdot p - 2p \cdot p_i + p_{i} \cdot p_{i}$
.........................................
(2) Find $p$ to minimize $f(p)$.
$\nabla f(p) = \sum_{i=1}^n 2(p - p_i) = 0$
$np = \sum_{i=1}^n p_i \rightarrow \frac{1}{n} \sum_{i=1}^n p_i = \bar{p}$
$\bar{p}$ is a critical point for $f(p)$
I wanted to know if $(p-\bar{p})$ is a critical point since $\nabla f(p) = 2n(p-\bar{p})$?
Writing the function as $$f(p) =\sum_{i=1}^n\langle p-p_i,p-p_i\rangle,$$we have $$Df(p)(v) =\sum_{i=1}^n 2\langle p-p_i,v\rangle.$$So, write this as $$Df(p)(v) =\left\langle 2np-\sum_{i=1}^n2p_i,v \right\rangle$$to conclude that $$\nabla f(p) = 2np-\sum_{i=1}^n2p_i. $$ So $\nabla f (p) $ is the zero vector if and only if $$p= \frac{1}{n}\sum_{i=1}^n p_i. $$To see that this gives the minimum, compute the Hessian: $$D^2f(\overline{p})(v,w) = 2n\langle v,w\rangle .$$Since $D^2f (\overline{p})$ is positive-definite, we are done.