GramSchmidt orthogonalization
Any set of linearly independent^{} vectors ${v}_{1},\mathrm{\dots},{v}_{n}$ can be converted into a set of orthogonal vectors^{} ${q}_{1},\mathrm{\dots},{q}_{n}$ by the GramSchmidt process^{}. In three dimensions^{}, ${v}_{1}$ determines a line; the vectors ${v}_{1}$ and ${v}_{2}$ determine a plane. The vector ${q}_{1}$ is the unit vector^{} in the direction ${v}_{1}$. The (unit) vector ${q}_{2}$ lies in the plane of ${v}_{1},{v}_{2}$, and is normal to ${v}_{1}$ (on the same side as ${v}_{2}$. The (unit) vector ${q}_{3}$ is normal to the plane of ${v}_{1},{v}_{2}$, on the same side as ${v}_{3}$, etc.
In general, first set ${u}_{1}={v}_{1}$, and then each ${u}_{i}$ is made orthogonal^{} to the preceding ${u}_{1},\mathrm{\dots}{u}_{i1}$ by subtraction of the projections of ${v}_{i}$ in the directions of ${u}_{1},\mathrm{\dots},{u}_{i1}$ :
$${u}_{i}={v}_{i}\sum _{j=1}^{i1}\frac{{u}_{j}^{T}{v}_{i}}{{u}_{j}^{T}{u}_{j}}{u}_{j}$$ 
The $i$ vectors ${u}_{i}$ span the same subspace^{} as the ${v}_{i}$. The vectors ${q}_{i}={u}_{i}/{u}_{i}$ are orthonormal. This leads to the following theorem:
Theorem.
Any $m\times n$ matrix $A$ with linearly independent columns can be factorized into a product, $A=QR$. The columns of $Q$ are orthonormal and $R$ is upper triangular and invertible^{}.
This “classical” GramSchmidt method is often numerically unstable, see [Golub89] for a “modified” GramSchmidt method.

•
Originally from The Data Analysis Briefbook (http://rkb.home.cern.ch/rkb/titleA.htmlhttp://rkb.home.cern.ch/rkb/titleA.html)

Golub89
Gene H. Golub and Charles F. van Loan: Matrix Computations, 2nd edn., The John Hopkins University Press, 1989.
Title  GramSchmidt orthogonalization 
Canonical name  GramSchmidtOrthogonalization 
Date of creation  20130322 12:06:14 
Last modified on  20130322 12:06:14 
Owner  akrowne (2) 
Last modified by  akrowne (2) 
Numerical id  9 
Author  akrowne (2) 
Entry type  Algorithm 
Classification  msc 65F25 
Synonym  GramSchmidt decomposition 
Synonym  GramSchmidt orthonormalization 
Synonym  GramSchmidt process 
Related topic  HouseholderTransformation 
Related topic  GivensRotation 
Related topic  QRDecomposition 
Related topic  AnExampleForSchurDecomposition 