Gram–Schmidt step
Remove earlier vector directions to build an orthogonal basis.
Gram–Schmidt step is one of 1 orthogonality formula in the linear algebra section of this library, and it is used at university level.
Why gram–schmidt step works
Subtracting the shadow of a vector on a direction removes everything it had in common with that direction, and what remains is perpendicular to it. Do this once for each direction you have already cleaned up, and the leftover is perpendicular to all of them, so the collection stays mutually perpendicular as it grows.
What each symbol means
$\mathbf v_k$ are independent input vectors and $\mathbf u_j$ orthogonal outputs.
Gram–Schmidt step: when it holds
The starting vectors must be linearly independent to avoid a zero denominator during normalization.
When it stops applying
If a vector is already a combination of the earlier ones, subtracting the shadows wipes it out completely and u_k comes back as the zero vector, which cannot be normalized. That outcome is a signal that your starting set was dependent, not a computational error.
Gram–Schmidt step: a worked example
From $(1,0)$ and $(1,1)$, the second orthogonal vector becomes $(0,1)$.
The mistake to avoid
What people do: Students subtract projections onto the original input vectors rather than onto the orthogonal ones already built.
Why it goes wrong: The original vectors overlap each other, so their shadows double-count the shared part and the result is not perpendicular to anything in particular.
Do this instead: Always project onto the finished u vectors. Starting from v₁ = (1, 1) and v₂ = (2, 0), set u₁ = (1, 1); then the shadow of v₂ on u₁ is (1, 1), so u₂ = (1, −1), and the check u₁ · u₂ = 1 − 1 = 0 confirms it.
Gram–Schmidt step: step by step
- Name the unknown, and the unit the answer has to come out in.
- Match the symbols to your values. $\mathbf v_k$ are independent input vectors and $\mathbf u_j$ orthogonal outputs.
- Check the conditions before substituting. The starting vectors must be linearly independent to avoid a zero denominator during normalization.
- Substitute, keep exact values to the last line, then test the sign, size, and unit against a rough estimate — the check that catches most linear algebra slips.
Where this formula fits
- Subject
- Linear Algebra formulas — 17 entries in this library
- Topic
- Orthogonality
- Level
- University
Formulas are easiest to keep when they sit inside a method rather than on a list. Use the links below to see where gram–schmidt step comes from, to check a calculation against a tool, and to practise it until you can recall it without looking.
- The Dot Product — the lesson behind this formula: measure alignment and test orthogonality.
- Orthogonal Vector Calculator — check your substitution and the value it produces.
- Study linear algebra — the subject guide that explains the ideas these formulas compress.
- Linear Algebra Practice — questions that make you retrieve the formula instead of recognising it.
- All 17 linear algebra formulas — the full grouped reference, or the complete formula library.
Questions about gram–schmidt step
Do I have to normalize at each step?
Not to get an orthogonal set, but you do to get an orthonormal one. Normalizing as you go also simplifies the arithmetic, since u · u becomes 1 and the projection denominators disappear.
Does the order of the input vectors matter?
Yes. The first vector always keeps its direction untouched, and every later one is cleaned relative to the ones before it, so reordering the inputs gives a different orthogonal basis for the same space.
What does this have to do with QR factorization?
The orthogonal vectors you build become the columns of Q, and the projection coefficients you compute along the way are exactly the entries of the upper triangular R.
Why do numerical libraries use a modified version?
Because subtracting all the shadows at once lets rounding errors accumulate. The modified version removes each shadow immediately and updates the vector before moving on, which keeps the result much closer to truly perpendicular.