Gram–Schmidt Orthonormalization Calculator

Convert linearly independent vectors into an orthonormal basis, view every projection, and verify A = QR. The calculator runs locally in your browser.

Enter Vectors as Matrix Columns

Each column is one vector. Enter integers, decimals, or scientific notation. Display precision does not round intermediate calculations.

Separate columns with spaces, commas, or tabs and rows with new lines. Rows are coordinates; columns are vectors. The matrix may have 2–8 rows and no more columns than rows.

Orthonormal Basis and QR Factors

Enter linearly independent vectors to calculate A = QR.

Q — orthonormal columns

R — coefficients

Orthonormal vectors
Max |QᵀQ − I|
Relative |A − QR|

Advertisement

Step-by-Step Gram–Schmidt Working

For vector aₖ, subtract its projection onto every earlier unit vector, then divide the remaining orthogonal vector uₖ by its length.

Calculate a valid set of vectors to see each projection and normalization.

Gram–Schmidt Formula and Output Convention

The input vectors are the columns of matrix A = [a₁ … aₙ]. The output columns q₁ … qₙ are orthonormal and span the same subspace.

Remove projections

uₖ = aₖ − Σⱼ<ₖ (qⱼᵀaₖ)qⱼ

Each subtraction removes the component pointing along an earlier basis vector.

Normalize

qₖ = uₖ / ‖uₖ‖

Dividing by the Euclidean norm makes each new basis vector have length 1.

QR factorization

A = QR,   QᵀQ = I

R is upper triangular and stores projection coefficients plus the residual norms on its diagonal.

Numerical method: This tool uses modified Gram–Schmidt, removing projections from the working vector one at a time. The optional second pass repeats those removals to reduce loss of orthogonality in floating-point arithmetic. Inputs and results are real numbers.

How to Use the Calculator

  1. Choose the coordinate dimension and number of vectors. A set cannot contain more independent vectors than its dimension.
  2. Enter each vector as a column of A, or paste the whole matrix. For example, the first column contains a₁.
  3. Select Orthonormalize vectors. The columns of Q are the resulting orthonormal basis.
  4. Review R, the projection steps, and both error checks. Copy the summary or download the matrices as CSV if needed.

Worked 3D Example

Start with a₁ = (1,1,0), a₂ = (1,0,1), and a₃ = (0,1,1). First, q₁ = (1/√2, 1/√2, 0). Removing the projection of a₂ onto q₁ gives a direction proportional to (1,−1,2), so q₂ = (1,−1,2)/√6. The third normalized residual is q₃ = (−1,1,1)/√3.

Same span

The new vectors are linear combinations of the originals, and A = QR reconstructs every original column.

Easy check

The basis is orthonormal when every qᵢ·qᵢ = 1 and every distinct pair has qᵢ·qⱼ = 0, subject to rounding.

Common Gram–Schmidt Problems

Dependent input vectors

If a vector lies in the span of earlier vectors, its residual is zero and cannot be normalized. Remove the redundant vector or choose an independent set.

Vectors entered as rows

This page treats columns as vectors. If your source lists one vector per row, transpose it before entry.

Rounding too early

Rounded projection coefficients can spoil later dot products. This calculator keeps full double precision internally and rounds only the display.

Gram–Schmidt FAQs

What does Gram–Schmidt orthonormalization calculate?

It replaces linearly independent vectors with mutually perpendicular unit vectors that span exactly the same subspace.

What is the difference between orthogonal and orthonormal?

Distinct orthogonal vectors have dot product zero. An orthonormal set is orthogonal and every vector also has Euclidean norm 1.

Why did the calculator report a dependent vector?

After earlier projections were removed, too little of that vector remained to create a reliable new direction. It is zero, dependent, or numerically indistinguishable from the span of earlier vectors at double precision.

What are the Q and R matrices?

Q contains the orthonormal basis vectors as columns. R is upper triangular and records how to combine those columns to reconstruct A.

Why use modified Gram–Schmidt?

It updates the residual after every projection, which generally preserves orthogonality better than evaluating the classical formula in its direct computational order. Re-orthogonalization can improve difficult cases further.

Can Gram–Schmidt change the order of the basis?

Yes. The process works from left to right, so reordering input vectors can produce a different orthonormal basis, although the final span remains the same for an independent set.

Are my vector entries private?

Yes. The calculation, clipboard text, and CSV file are created in your browser. This calculator’s code does not transmit or save the entered values.

Calculation Notes

Last reviewed: August 4, 2026 by the Starlight Tools editorial team.

Inputs must be finite and no larger than 10¹⁰⁰ in magnitude. Dimensions are limited to 8 so the complete working stays readable. Dependence is assessed relative to each vector’s original norm and JavaScript double-precision arithmetic; severely ill-conditioned inputs may require specialist numerical software or higher precision.

Explore more tools