The goal is to show the cost function $$J(x) = \sum_{k=1}^n ||x - x_k ||^2$$ is minimized when $x = m$, where $m$ is the sample mean $m = \frac1n \sum_{k=1}^n x_k$
I would like to stay as general as possible and consider a normed vector space $\left(X, ||\cdot||\right)$ where $x_1, ..., x_n$ are given points in $X$.
I came across this previous post Formal proof that mean minimize squared error function. In their proof, they used :
\begin{align} J(x) &= \sum_{k=1}^n ||(x-m) - (x_k - m)||^2 \\ &= \sum_{k=1}^n ||x-m||^2 - 2(x-m)^T \sum_{k=1}^n (x_k-m) + \sum_{k=1}^n ||x_k - m||^2 \end{align}
I wonder how they got the second term $2(x-m)^T \sum_{k=1}^n (x_k-m)$ ?
My guess is that they used the identity $||a-b||^2 = ||a||^2 - 2 a \cdot b + ||b||^2$. However this identity assumes that the inner product $a \cdot b$ is defined, which is not always the case in general. What if the norm we're considering isn't induced by an inner product ?
How would this proof be extended to normed vector spaces that don't have an inner product ?
EDIT : The answers have pointed out that this claim isn't true in general (see counter-example below).
As a follow-up question : is it true for $n=2$ ? That is, given two points $x_1$ and $x_2$ in $X$, does $\frac12 (x_1 + x_2)$ always minimize $J$ ?