# finding minimum and maximum with equality constraints

Let $a_1,a_2,...,a_m \in \mathbb R^n$. Let $$f(x) = \sum_{j=1}^m ||x-a_j||^2$$

Find a local minima and maxima subject to a constraint $||x||^2 = 1$.

Consider a balance point $\hat a = \frac 1m \sum_{j=1}^m a_j$. Show that if $\hat a \neq 0$, then the function $f$ has one minimum and one maximum. Consider a case when $\hat a \neq 0$.

Hint: observe that, if $|x|=1$, $$f(x) = \sum_{j=1}^m (|x|^2 - 2\langle x, a_j\rangle + |a_j|^2) = C - 2 \langle x, \hat{a}\rangle,$$ where $C := m + \sum_{j=1}^m |a_j|^2$.
If $\hat{a}\neq 0$, then max and min on $|x|^2=1$ are achieved respectively at $\mp \hat{a} / |\hat{a}|$. If $\hat{a} = 0$, then your function is constant.