This is documentation for Mathematica 5.2, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Gram-Schmidt Orthogonalization

Gram-Schmidt orthogonalization generates an orthonormal basis from an arbitrary basis. An orthonormal basis is a basis,  , for which

In Mathematica a Gram-Schmidt orthogonalization can be computed from a set of vectors with the package function GramSchmidt, which is defined in the package LinearAlgebra`Orthogonalization`.

This loads the package.

In[1]:= 

This creates a set of three vectors that form a basis for  .

In[2]:= 

A plot visualizes the vectors; they all tend to lie in the same direction.

In[5]:= 

This computes an orthonormal basis.

In[6]:= 

Out[6]=

The orthonormal vectors are obviously much more spread out.

In[7]:= 

The vectors v1, v2, and v3 are orthonormal, thus the dot product of each vector with itself is 1.

In[8]:= 

Out[8]=

In addition, the dot product of a vector with another vector is 0.

In[9]:= 

Out[9]=

This uses Outer to compare all vectors with all other vectors.

In[10]:= 

Out[10]=