Gram-schmidt decomposition
Any set of linearly independent vectors can be converted into a set of orthogonal vectors by the Gram-Schmidt process. In three dimensions v1 determines a line; the vectors v1 and v2 determine a plane. The vector q1 is the unit vector in the direction v1. The (unit) vector q2 lies in the plane of v1, v2, and is normal to v1 (on the same side as v2). The (unit) vector q3 is normal to the plane of v1, v2, on the same side as v3.
In general, first set u1= v1, and then each ui is made orthogonal to the preceding by subtraction of the projections of vi in the directions of :
The i vectors ui span the same subspace as the vi. The vectors are orthonormal. This leads to the following theorem:
Any (m,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 Gram-Schmidt method is often numerically unstable, see Golub89 for a ``modified Gram-Schmidt method.