> [!NOTE] Theorem (Gram-Schmidt orthogonalisation) > Let $V=\mathbb{R}^{n},$ equipped [[Dot Product in Real n-Space|dot product]]. If $v_{1},\dots,v_{n}$ is a basis of $V,$ then the following algorithm determines an [[Orthonormal Subset of Euclidean Space|orthonormal]] [[Basis of Vector Space|basis]] of $V:$ $\begin{align} w_{1} &= \frac{1}{|| v_{1} | |} v_{1} \\ w_{2}' = v_{2} - (v_{2} \cdot w_{1})w_{1}, \quad w_{2} &= \frac{1}{||w_{2}'||} w'_{2} \\ \vdots \\ w_{n}' = v_{n} - \sum_{k=1}^{n-1} (v_{n} \cdot w_{k})w_{k}, \quad w_{n} &= \frac{1}{|| w_{n}' ||} w_{n} \end{align}$where at each step $w_{1},\dots,w_{i}$ is an orthonormal basis of its span $\langle w_{1},\dots,w_{i}\rangle =\langle v_{1},\dots,v_{i}\rangle.$ *Proof*. Certainly $v_{1}\neq 0_{V}$ so $w_{1}$ is defined and $\langle w_{1} \rangle = \langle v_{1} \rangle.$ Suppose inductively we have $w_{1},\dots,w_{i-1}$ as claimed. Then $u_{i}$ is defined and lies in $\langle w_{1},\dots,w_{i-1},v_{i} \rangle = \langle v_{1},\dots,v_{i-1},v_{i} \rangle.$ Note that $u_{i}=0_{V},$ otherwise $v_{i}$ would be in span of of $\langle w_{1},\dots,w_{i-1} \rangle=\langle v_{1},\dots,v_{i-1} \rangle,$ contradicting the linear independence of $v_{1},\dots,v_{n}.$ So $w_{i}$ is defined, it has $||w_{i}||=1,$ and by [[Linear Independence#^c97b84|exchange lemma]] it is linearly independent of $w_{1},\dots,w_{i-1}.$ If $j<i$ then since by induction $w_1,\ldots,w_{i-1}$ is orthonormal, then for the nonzero scalar $\alpha=\frac1{\|u_i\|}$, $\begin{aligned} w_{i}\cdot w_{j}& =\quad\alpha\left(v_i-\sum_{k=1}^{i-1}(v_i\cdot w_k)w_k)\right)\cdot w_j \\ &\begin{array}{cc}=&0\end{array} \end{aligned}$and so $w_1,\ldots,w_i$ are orthonormal as required.