# Closest Vector in a Inner Product Space

Let $V$ = $\mathbb{R}^n$

Note that $\langle -,-\rangle$ defines the Inner Product on $\mathbb{R}^n$

$$\|v\| = \sqrt{\langle v,v \rangle}$$

Consider the standard Distance Function $$d(x,y) = \|x-y\|$$

Let $W$ $\subset V$ be a Subspace of Dimension $n-1$ defined by the equation

$W = {(x_1,......,x_n)} : {x_1+x_2+.....x_n=0}$

Show that the vector in $W$ closest to the vector $(x_1,.....,x_n)$ is the vector $$(x-\lambda,.....,x_n-\lambda)$$

where $\lambda = \frac{x_1+....+x_n}{n}$

How do I go about this? I'm a little confused since I've been taught almost like an algorithim that the orthogonal projection via gram schmidt is the closest vector but I'm not able to use it here properly. Is there a proper way to approach such problems?

Hint: Because $W$ is a hyperplane defined by a single linear equation, its orthogonal complement $W^{\perp}$ can be read off its defining equation: $$W^{\perp} = \operatorname{Span}\{\mathbf{1}\} = \operatorname{Span}\{(1, 1, \dots, 1)\}.$$ Now decompose an arbitrary vector $x$ as \begin{align*} x &= \operatorname{proj}_{W}(x) + \operatorname{proj}_{W^{\perp}}(x) \\ &= \bigl(x - \operatorname{proj}_{\mathbf{1}}(x)\bigr) + \operatorname{proj}_{\mathbf{1}}(x). \end{align*}