Gram-Schmidt and QR Calculator
Turn any vectors into perpendicular ones, exactly. Follow each projection as it's subtracted, then read off the orthonormal basis and the QR factors.
Vectors
Enter up to 8 vectors of the same length, or start from an example.
Result
Updates as you type.
Every vector adds a new direction, so the result has 3 perpendicular vectors.
Orthogonal basis
Orthonormal basis
QR factors
With your vectors as the columns of A, Q holds the orthonormal basis and R is upper triangular.
One projection at a time
Take the vectors in order. From each one, remove its part along every finished vector, and what's left is perpendicular to all of them.
What the Gram-Schmidt process does
The Gram-Schmidt process takes a set of vectors and returns perpendicular vectors with the same span. It works through them in order. From each vector, it removes the part along every vector already finished:
Each fraction times is a projection, which you can explore on its own with the Vector Projection Calculator. What remains has no part left along any earlier vector, so it's perpendicular to all of them. If nothing remains, that vector was already a combination of the earlier ones, which the Linear Independence and Span Calculator looks at directly.
Orthogonal, then orthonormal
Perpendicular vectors form an orthogonal basis. Dividing each one by its length gives an orthonormal basis, whose vectors all have length 1:
The orthogonal vectors stay plain fractions, because they only use addition, multiplication, and division. Square roots appear only at this last step, which is why this calculator can keep every value exact.
QR factorization
Place your vectors as the columns of a matrix , and the process factors it as:
holds the orthonormal vectors as its columns, so . is upper triangular, and its entries record the process: the diagonal holds the lengths , and the entries above it hold .
QR is useful because solving with it is stable and simple. To solve or a Least Squares Calculator problem, you can solve , which only needs back substitution. Computer programs usually use a more stable variant of this process because they round numbers, but exact arithmetic has no such concern.
Related calculators
Keep working with vectors and matrices.
Vector Projection Calculator
Project one vector onto another in exact fractions. Get the vector projection, scalar projection, and orthogonal remainder, and see the projection as a shadow.
Linear Independence and Span Calculator
Check whether vectors are linearly independent, with exact dependency relations like v₃ = 2v₁ − v₂. Find a basis for the span, and watch it grow from a line to a plane to space.
Dot Product and Angle Calculator
Find the dot product, magnitudes, unit vectors, and the angle between two vectors, with exact roots like √14. Drag vectors and watch the sign change at 90°.