Gram-Schmidt orthogonalization calculator
Subtracts projections from v₁, v₂, … to build mutually orthogonal u₁, u₂, ….
INPUT
Integers, fractions (1/3) and decimals (0.25) are accepted. Empty cells count as 0. Paste a block of numbers from a spreadsheet or textbook into the first cell to fill the whole matrix.
RESULT
LaTeX is the math code you can paste into Overleaf, Notion equation blocks or Word's equation editor.
Steps
What is the Gram-Schmidt process?
Subtracting from each vector its components along the previously built vectors leaves mutually perpendicular vectors: uₖ = vₖ − Σ (vₖ·uⱼ)/(uⱼ·uⱼ) uⱼ.
Dividing each result by its length gives an orthonormal basis. Since lengths usually involve square roots, the calculator shows the unnormalized u and ‖u‖².
Exam tipIf uₖ comes out as 0, vₖ is a combination of the earlier vectors: drop it and move on.
How to do it by hand
- Keep the first vector as it is: u₁ = v₁.
- From the second vector, subtract its component along u₁: u₂ = v₂ − (v₂·u₁)/(u₁·u₁) · u₁. What remains is orthogonal to u₁.
- From the third onward, subtract the projection onto every u found so far: u₃ = v₃ − proj_u₁(v₃) − proj_u₂(v₃).
- If you need an orthonormal basis, divide each u by its length at the very end. Normalizing earlier just makes the fractions messier.
- If some u comes out as the zero vector, that v was dependent on the earlier ones. Drop it and continue.
Orthogonalize v₁ = (1, 1, 0), v₂ = (1, 0, 1).
u₁ = (1, 1, 0)
v₂·u₁ = 1, u₁·u₁ = 2 → u₂ = (1, 0, 1) − ½(1, 1, 0) = (½, −½, 1)
Check: u₁·u₂ = ½ − ½ + 0 = 0 ✓. Normalized: e₁ = (1,1,0)/√2, e₂ = (1,−1,2)/√6.
Where is it used?
- The core of QR decomposition: in A = QR the columns of Q are the orthonormal vectors from Gram-Schmidt. It solves least-squares problems stably.
- Signal processing builds bases whose components do not interfere (orthogonal bases). The sines and cosines of Fourier series are one example.
- Projections: with an orthogonal basis, projecting any vector onto a subspace takes just a few dot products.
Common mistakes
- Subtracting only the projection onto u₁ from the third vector and forgetting u₂. You must subtract the projection onto every earlier u.
- Projecting onto the original v₁ instead of the orthogonalized u₁. They coincide for the first vector but differ from the second onward.
- Writing |u| in the denominator. The projection coefficient is (v·u)/(u·u); the denominator is the squared length.
How to use
- Set the matrix size with the row and column buttons. Up to 6×6 is supported.
- Type numbers into the cells and the result updates instantly. Enter fractions as
1/3and negatives as-2. - Enter moves to the next cell; the ← → ↑ ↓ arrow keys move between cells.
- Open ‘Steps’ to see the full working. ‘Copy LaTeX’ copies the result as math code you can paste into Overleaf, a Notion equation block or Word's equation editor.
FAQ
- Where do I enter the vectors?
- Each column of the matrix is one vector. For two vectors in ℝ³, enter a 3×2 matrix.
- Why no orthonormal basis?
- Normalizing introduces square roots that cannot be written as exact fractions, so the calculator gives the orthogonal u and ‖u‖². Divide u by √(‖u‖²) to normalize.
- How does this relate to QR?
- The normalized vectors as columns form Q, and R = QᵀA.
Related guides
- Gram-Schmidt Process: Formula, Example and QR DecompositionSubtract projections to make mutually perpendicular vectors, with dependent vectors and normalization covered too.
- How to Test Vectors for Linear Independence (Using Rank)Test linear independence by putting the vectors in columns and finding the rank, with worked examples.
- How to Find a Basis for the Null Space and Column Space (RREF Example)How to read bases for the null space and column space off the RREF, with a worked example.