The Gram-Schmidt process is an algorithm to convert a basis for some vector space to an orthonormal basis .

The step is first find an orthogonal basis and then normalize.

The algorithm is following:

  • normalize the first vector
  • subtract any component of the 1st vector from the 2nd one (by subtracting the projection)
  • repeat by normalize the kth vector, subtract components of first k vectors from vector k+1

Alternatives

  • In the case of 3D math, we can use cross product to get an orthonormal basis.
  • For large number of vectors/nearly parallel vectors, Gram-Schmidt is not the best algorithm numerically. Instead, QR decomposition is a better alternative.
  • Gram-Schmidt is a sequential algorithm since calculation of normal vector depends on the value of previous normal vector . However, there are parallel variants.