Advertisement

Gram-Schmidt calculator

Choose the number of vectors and coordinates, then enter each vector as one row. The calculator subtracts projections onto earlier vectors and normalizes the result.

Calculator

Orthonormal vectors, one per row
1, 0; 0, 1
Number of orthonormal vectors
2.00000000
Result
Orthonormal basis of 2 vectors.

Advertisement

How this calculator works

Gram-Schmidt takes the first vector, divides it by its length to make it unit length, then removes its component from each later vector before normalizing that vector. The result is an orthonormal set with the same span as the input, provided the input vectors are independent. If a later vector becomes zero after projection, the input is dependent and the process stops there. This calculator uses modified Gram-Schmidt with a second orthogonalization pass, which limits the loss of orthogonality from rounding.

Formula

u1 = v1, e1 = u1/||u1||. Then uk = vk - sum over j < k of (vk dot ej) ej, and ek = uk/||uk||.

Worked example

For the vectors 1, 0 and 2, 3, the first is already unit length. The projection of 2, 3 onto it is 2, 0, leaving 0, 3, which normalizes to 0, 1. The orthonormal set is 1, 0 and 0, 1. The vectors 1, 0 and 2, 0 are dependent because the second lies on the first.

Advertisement

Frequently asked questions

Does the order of the vectors change the result?

Yes. Different input orders can produce different orthonormal bases for the same span, because the process privileges earlier vectors.

What happens with dependent vectors?

One projection becomes zero, so the new vector cannot be normalized. The calculator stops and reports which input vector became dependent.

How does this relate to QR decomposition?

Applying Gram-Schmidt to the columns of a matrix produces the same Q and R factors as QR decomposition, although Householder QR is usually more stable.

Sources

Advertisement