# Hilbert projection theorem

In mathematics, the Hilbert projection theorem is a famous result of convex analysis that says that for every vector $x$ in a Hilbert space $H$ and every nonempty closed convex $C\subseteq H,$ there exists a unique vector $m\in C$ for which $\|c-x\|$ is minimized over the vectors $c\in C$; that is, such that $\|m-x\|\leq \|c-x\|$ for every $c\in C.$

## Finite dimensional case

Some intuition for the theorem can be obtained by considering the first order condition of the optimization problem.
Consider a finite dimensional real Hilbert space $H$ with a subspace $C$ and a point $x.$ If $m\in C$ is a minimizer or minimum point of the function $N:C\to \mathbb {R}$ defined by $N(c):=\|c-x\|$ (which is the same as the minimum point of $c\mapsto \|c-x\|^{2}$), then derivative must be zero at $m.$
In matrix derivative notation ${\begin{aligned}\partial \lVert x-c\rVert ^{2}&=\partial \langle c-x,c-x\rangle \\&=2\langle c-x,\partial c\rangle \end{aligned}}$ Since $\partial c$ is a vector in $C$ that represents an arbitrary tangent direction, it follows that $m-x$ must be orthogonal to every vector in $C.$

## Statement

Hilbert projection theorem — For every vector $x$ in a Hilbert space $H$ and every nonempty closed convex $C\subseteq H,$ there exists a unique vector $m\in C$ for which $\lVert x-m\rVert$ is equal to $\delta :=\inf _{c\in C}\|x-c\|.$
If the closed subset $C$ is also a vector subspace of $H$ then this minimizer $m$ is the unique element in $C$ such that $x-m$ is orthogonal to $C.$

### Detailed elementary proof

Let $\delta :=\inf _{c\in C}\|x-c\|$ be the distance between $x$ and $C,$ $\left(c_{n}\right)_{n=1}^{\infty }$ a sequence in $C$ such that the distance squared between $x$ and $c_{n}$ is less than or equal to $\delta ^{2}+1/n.$ Let $n$ and $m$ be two integers, then the following equalities are true: $\left\|c_{n}-c_{m}\right\|^{2}=\left\|c_{n}-x\right\|^{2}+\left\|c_{m}-x\right\|^{2}-2\left\langle c_{n}-x\,,\,c_{m}-x\right\rangle$ and $4\left\|{\frac {c_{n}+c_{m}}{2}}-x\right\|^{2}=\left\|c_{n}-x\right\|^{2}+\left\|c_{m}-x\right\|^{2}+2\left\langle c_{n}-x\,,\,c_{m}-x\right\rangle$ Therefore $\left\|c_{n}-c_{m}\right\|^{2}=2\left\|c_{n}-x\right\|^{2}+2\left\|c_{m}-x\right\|^{2}-4\left\|{\frac {c_{n}+c_{m}}{2}}-x\right\|^{2}$ (This equation is the same as the formula $a^{2}=2b^{2}+2c^{2}-4M_{a}^{2}$ for the length $M_{a}$ of a median in a triangle with sides of length $a,b,$ and $c,$ where specifically, the triangle's vertices are $x,c_{m},c_{n}$).
By giving an upper bound to the first two terms of the equality and by noticing that the middle of $c_{n}$ and $c_{m}$ belong to $C$ and has therefore a distance greater than or equal to $\delta$ from $x,$ it follows that: $\|c_{n}-c_{m}\|^{2}\;\leq \;2\left(\delta ^{2}+{\frac {1}{n}}\right)+2\left(\delta ^{2}+{\frac {1}{m}}\right)-4\delta ^{2}=2\left({\frac {1}{n}}+{\frac {1}{m}}\right)$
The last inequality proves that $\left(c_{n}\right)_{n=1}^{\infty }$ is a Cauchy sequence. Since $C$ is complete, the sequence is therefore convergent to a point $m\in C,$ whose distance from $x$ is minimal. $\blacksquare$
Let $m_{1}$ and $m_{2}$ be two minimum points. Then: $\|m_{2}-m_{1}\|^{2}=2\|m_{1}-x\|^{2}+2\|m_{2}-x\|^{2}-4\left\|{\frac {m_{1}+m_{2}}{2}}-x\right\|^{2}$
Since ${\frac {m_{1}+m_{2}}{2}}$ belongs to $C,$ we have $\left\|{\frac {m_{1}+m_{2}}{2}}-x\right\|^{2}\geq \delta ^{2}$ and therefore $\|m_{2}-m_{1}\|^{2}\leq 2\delta ^{2}+2\delta ^{2}-4\delta ^{2}=0.$
Hence $m_{1}=m_{2},$ which proves uniqueness. $\blacksquare$
Assume that $C$ is a closed vector subspace of $H.$ It must be shown the minimizer $m$ is the unique element in $C$ such that $\langle m-x,c\rangle =0$ for every $c\in C.$
Proof that the condition is sufficient: Let $z\in C$ be such that $\langle z-x,c\rangle =0$ for all $c\in C.$ If $c\in C$ then $c-z\in C$ and so $\|c-x\|^{2}=\|(z-x)+(c-z)\|^{2}=\|z-x\|^{2}+\|c-z\|^{2}+2\langle z-x,c-z\rangle =\|z-x\|^{2}+\|c-z\|^{2}$ which implies that $\|z-x\|^{2}\leq \|c-x\|^{2}.$ Because $c\in C$ was arbitrary, this proves that $\|z-x\|=\inf _{c\in C}\|c-x\|$ and so $z$ is a minimum point.
Proof that the condition is necessary: Let $m\in C$ be the minimum point. Let $c\in C$ and $t\in \mathbb {R} .$ Because $m+tc\in C,$ the minimality of $m$ guarantees that $\|m-x\|\leq \|(m+tc)-x\|.$ Thus $\|(m+tc)-x\|^{2}-\|m-x\|^{2}=2t\langle m-x,c\rangle +t^{2}\|c\|^{2}$ is always non-negative and $\langle m-x,c\rangle$ must be a real number. If $\langle m-x,c\rangle \neq 0$ then the map $f(t):=2t\langle m-x,c\rangle +t^{2}\|c\|^{2}$ has a minimum at $t_{0}:=-{\frac {\langle m-x,c\rangle }{\|c\|^{2}}}$ and moreover, $f\left(t_{0}\right)<0,$ which is a contradiction. Thus $\langle m-x,c\rangle =0.$ $\blacksquare$

### Proof by reduction to a special case

It suffices to prove the theorem in the case of $x=0$ because the general case follows from the statement below by replacing $C$ with $C-x.$
Hilbert projection theorem (case $x=0$) — For every nonempty closed convex subset $C\subseteq H$ of a Hilbert space $H,$ there exists a unique vector $m\in C$ such that $\inf _{c\in C}\|c\|=\|m\|.$
Furthermore, letting $d:=\inf _{c\in C}\|c\|,$ if $\left(c_{n}\right)_{n=1}^{\infty }$ is any sequence in $C$ such that $\lim _{n\to \infty }\left\|c_{n}\right\|=d$ in $\mathbb {R}$ then $\lim _{n\to \infty }c_{n}=m$ in $H.$
Let $C$ be as described in this theorem and let $d:=\inf _{c\in C}\|c\|.$ This theorem will follow from the following lemmas.
Lemma 1 — If $c_{\bullet }:=\left(c_{n}\right)_{n=1}^{\infty }$ is any sequence in $C$ such that $\lim _{n\to \infty }\left\|c_{n}\right\|=d$ in $\mathbb {R}$ then there exists some $c\in C$ such that $\lim _{n\to \infty }c_{n}=c$ in $H.$ Furthermore, $\|c\|=d.$
Lemma 2 — A sequence $\left(c_{n}\right)_{n=1}^{\infty }$ satisfying the hypotheses of Lemma 1 exists.
Lemma 2 and Lemma 1 together prove that there exists some $c\in C$ such that $\|c\|=d.$ Lemma 1 can be used to prove uniqueness as follows. Suppose $b\in C$ is such that $\|b\|=d$ and denote the sequence $b,c,b,c,b,c,\ldots$ by $\left(c_{n}\right)_{n=1}^{\infty }$ so that the subsequence $\left(c_{2n}\right)_{n=1}^{\infty }$ of even indices is the constant sequence $c,c,c,\ldots$ while the subsequence $\left(c_{2n-1}\right)_{n=1}^{\infty }$ of odd indices is the constant sequence $b,b,b,\ldots .$ Because $\left\|c_{n}\right\|=d$ for every $n\in \mathbb {N} ,$ $\lim _{n\to \infty }\left\|c_{n}\right\|=\lim _{n\to \infty }d=d$ in $\mathbb {R} ,$ which shows that the sequence $\left(c_{n}\right)_{n=1}^{\infty }$ satisfies the hypotheses of Lemma 1. Lemma 1 guarantees the existence of some $x\in C$ such that $\lim _{n\to \infty }c_{n}=x$ in $H.$ Because $\left(c_{n}\right)_{n=1}^{\infty }$ converges to $x,$ so do all of its subsequences. In particular, the subsequence $c,c,c,\ldots$ converges to $x,$ which implies that $x=c$ (because limits in $H$ are unique and this constant subsequence also converges to $c$). Similarly, $x=b$ because the subsequence $b,b,b,\ldots$ converges to both $x$ and $b.$ Thus $b=c,$ which proves the theorem. $\blacksquare$

## Consequences

Proposition — If $C$ is a closed vector subspace of a Hilbert space $H$ then $H=C\oplus C^{\bot }.$

## Properties

Expression as a global minimum
The statement and conclusion of the Hilbert projection theorem can be expressed in terms of global minimums of the followings functions. Their notation will also be used to simplify certain statements.
Given a non-empty subset $C\subseteq H$ and some $x\in H,$ define a function $d_{C,x}:C\to [0,\infty )\quad {\text{ by }}c\mapsto \|x-c\|.$ A global minimum point of $d_{C,x},$ if one exists, is any point $m$ in $\,\operatorname {domain} d_{C,x}=C\,$ such that $d_{C,x}(m)\,\leq \,d_{C,x}(c)\quad {\text{ for all }}c\in C,$ in which case $d_{C,x}(m)=\|m-x\|$ is equal to the global minimum value of the function $d_{C,x},$ which is: $\inf _{c\in C}d_{C,x}(c)=\inf _{c\in C}\|x-c\|.$
Effects of translations and scalings
When this global minimum point $m$ exists and is unique then denote it by $\min(C,x);$ explicitly, the defining properties of $\min(C,x)$ (if it exists) are: $\min(C,x)\in C\quad {\text{ and }}\quad \left\|x-\min(C,x)\right\|\leq \|x-c\|\quad {\text{ for all }}c\in C.$ The Hilbert projection theorem guarantees that this unique minimum point exists whenever $C$ is a non-empty closed and convex subset of a Hilbert space. However, such a minimum point can also exist in non-convex or non-closed subsets as well; for instance, just as long is $C$ is non-empty, if $x\in C$ then $\min(C,x)=x.$
If $C\subseteq H$ is a non-empty subset, $s$ is any scalar, and $x,x_{0}\in H$ are any vectors then $\,\min \left(sC+x_{0},sx+x_{0}\right)=s\min(C,x)+x_{0}$ which implies: ${\begin{alignedat}{6}\min &(sC,sx)&&=s&&\min(C,x)\\\min &(-C,-x)&&=-&&\min(C,x)\\\end{alignedat}}$ ${\begin{alignedat}{6}\min \left(C+x_{0},x+x_{0}\right)&=\min(C,x)+x_{0}\\\min \left(C-x_{0},x-x_{0}\right)&=\min(C,x)-x_{0}\\\end{alignedat}}$ ${\begin{alignedat}{6}\min &(C,-x)&&=\min(C+x,0)-x\\\min &(C,0)\;+\;x\;\;\;\;&&=\min(C+x,x)\\\min &(C-x,0)&&=\min(C,x)-x\\\end{alignedat}}$
Examples
The following counter-example demonstrates a continuous linear isomorphism $A:H\to H$ for which $\,\min(A(C),A(x))\neq A(\min(C,x)).$ Endow $H:=\mathbb {R} ^{2}$ with the dot product, let $x_{0}:=(0,1),$ and for every real $s\in \mathbb {R} ,$ let $L_{s}:=\{(x,sx):x\in \mathbb {R} \}$ be the line of slope $s$ through the origin, where it is readily verified that $\min \left(L_{s},x_{0}\right)={\frac {s}{1+s^{2}}}(1,s).$ Pick a real number $r\neq 0$ and define $A:\mathbb {R} ^{2}\to \mathbb {R} ^{2}$ by $A(x,y):=(rx,y)$ (so this map scales the $x-$coordinate by $r$ while leaving the $y-$coordinate unchanged). Then $A:\mathbb {R} ^{2}\to \mathbb {R} ^{2}$ is an invertible continuous linear operator that satisfies $A\left(L_{s}\right)=L_{s/r}$ and $A\left(x_{0}\right)=x_{0},$ so that $\,\min \left(A\left(L_{s}\right),A\left(x_{0}\right)\right)={\frac {s}{r^{2}+s^{2}}}(1,s)$ and $A\left(\min \left(L_{s},x_{0}\right)\right)={\frac {s}{1+s^{2}}}\left(r,s\right).$ Consequently, if $C:=L_{s}$ with $s\neq 0$ and if $(r,s)\neq (\pm 1,1)$ then $\,\min(A(C),A\left(x_{0}\right))\neq A\left(\min \left(C,x_{0}\right)\right).$