In mathematics and numerical analysis, the GramSchmidt process of linear algebra is a method of orthogonalizing a set of vectors in an inner product space, most commonly the Euclidean space R^{n}. Orthogonalization in this context means the following: we start with vectors v_{1},...,v_{k} which are linearly independent and we want to find mutually orthogonal vectors u_{1},...,u_{k} which generate the same subspace as the vectors v_{1},...,v_{k}. The method is named for Jorgen Pedersen Gram and Erhard Schmidt, but is older, and to be found in the work of Laplace and Cauchy. In the theory of Lie group decompositions it is generalized by the Iwasawa decomposition. The GramSchmidt process is numerically unstable: when implemented on a computer, the vectors u_{k} are not quite orthogonal because of rounding errors, and for the GramSchmidt process the loss of orthogonality is particularly bad. Therefore one usually prefers to use Householder transformations or Givens rotations.
The GramSchmidt process
We define the projection operator by 
The GramSchmidt process then works as follows: The sequence u_{1},...,u_{k} is the required system of orthogonal vectors, and the normalized vectors e_{1},...,e_{k} form an orthonormal system. To check that these formulas yield an orthogonal sequence, first compute <u_{1}, u_{2}> by substituting the above formula for u_{2}: you will get zero. Then use this to compute <u_{1}, u_{3}> again by substituting the formula for u_{3}: you will get zero. The general proof proceeds by mathematical induction. Geometrically, this method proceeds as follows: to compute u_{i}, it projects v_{i} orthogonally onto the subspace U generated by u_{1},...,u_{i1}, which is the same as the subspace generated by v_{1},...,v_{i1}. u_{i} is then defined to be the difference between v_{i} and this projection, guaranteed to be orthogonal to all of the vectors in the subspace U. The GramSchmidt process also applies to a linearly independent infinite sequence {v_{i}}_{i}. The result is an orthogonal (or orthonormal) sequence {u_{i}}_{i} such that for natural number n: the algebraic span of v_{1},...,v_{n} is the same as that of u_{1},...,u_{n}.
Example Consider the following set of vectors in R^{n} (with the conventional inner product) Now, perform GramSchmidt, to obtain an orthogonal set of vectors: 
We check that the vectors u_{1} and u_{2} are indeed orthogonal: 
