Let $V$ be a real or complex [inner product space](/page/Inner%20Product%20Space) whose [inner product](/page/Inner%20Product) $(\cdot,\cdot)_V$ is linear in the first variable, and let $W \subset V$ be a finite-dimensional subspace. Let $(e_1,\ldots,e_k)$ be an [orthonormal basis](/page/Orthonormal%20Basis) of $W$, where $k$ is a nonnegative integer and the case $k=0$ means $W=\{0\}$. For every $v \in V$, define
with the empty sum interpreted as $0$ when $k=0$. Then $w_0$ is the unique least-squares approximation to $v$ from $W$: it is the unique vector in $W$ such that