b2KIT

Gram-Schmidt Process Visualizer

Watch the Gram-Schmidt orthogonalization process step by step in 2D and 3D with animated projections.

Tested tool guide Tested browser tools Checked August 16, 2026

What Gram-Schmidt Process Visualizer does, with a checked example

Feed in a set of vectors in 2D or 3D and the tool replays the Gram-Schmidt orthogonalization process as an animation: each vector is projected onto the span of the vectors processed before it, the projection is subtracted, and the perpendicular leftover is normalized to unit length. Every step shows the original vectors, the projection arrow, and the growing orthonormal basis. The most common surprise is that the output depends on the order you enter the vectors: the same set in a different order yields a different orthonormal basis, and a nearly dependent vector produces a tiny leftover that gets stretched into a full-size unit vector.

Worked example

A concrete input and expected output from the current implementation.

Input

v1 = (3, 4), v2 = (1, 2)  [2D]

Expected output

u1 = (0.6, 0.8), u2 = (-0.8, 0.6); the step-2 projection of v2 onto u1 is shown as the vector (1.32, 1.76), which has length 2.2, and the QR factorization is R = [[5, 2.2], [0, 0.4]]

The first vector is normalized to unit length: (3, 4) / 5 = (0.6, 0.8). The projection of (1, 2) onto u1 has length 2.2; subtracting it leaves (-0.32, 0.24), whose norm is 0.4, and normalizing gives (-0.8, 0.6). The two results are unit vectors and perpendicular, since 0.6 * -0.8 + 0.8 * 0.6 = 0.

How the result is produced

1

Left-to-right processing

Vectors are handled left to right, in the order entered. The first is scaled to unit length and becomes the first basis vector. Each later vector is projected onto the span of the basis vectors built so far, the projection is subtracted off, and the perpendicular remainder is normalized. If that remainder is zero, the vector is a linear combination of earlier ones and drops out of the basis.

2

The projection arithmetic

Each step is an inner-product pass: the current vector is dotted with every finished basis vector, each basis vector is scaled by its dot product, and the scaled vectors are subtracted from the current one. Because the finished basis is orthonormal, the subtractions are independent and each one removes exactly one direction. The same numbers form a QR factorization: the orthonormal basis vectors are the columns of Q, and the lengths and inner products computed at each step are the entries of R.

Good uses

  • Checking a hand-computed orthonormal basis before an exam: enter the vectors and let the animation confirm each projection, leftover, and normalization, including the vectors that turn out dependent.
  • Preparing the orthonormal basis that a least-squares or projection problem needs, when you want the intermediate projections visible instead of a black-box QR routine.
  • Teaching or relearning the geometry: enter two or three vectors at an awkward angle and watch the projection arrow appear and get subtracted, the step most textbook figures leave implicit.

Limits and checks

  • Order dependence: the same vectors entered in a different order produce a different orthonormal basis. The span is identical but the basis vectors are not, so results can only be interpreted relative to the order you chose.
  • Dependence: a vector that is a linear combination of earlier vectors yields a zero leftover and drops out, so the output can contain fewer basis vectors than you entered. In 2D, any third vector is dependent and disappears.
  • Normalization: the final vectors always have unit length. The unnormalized perpendicular leftovers shown mid-step are not the answer, and for nearly parallel inputs those leftovers are so short that rounding can dominate the final direction.

Common questions

The orthonormal version of my second vector points somewhere I did not expect. Is that wrong?

No. Each vector is replaced by its part perpendicular to everything processed before it, then stretched to unit length. The projection being subtracted is often much longer than the leftover, so the direction changes dramatically; only the first vector keeps its original direction. What stays fixed is the span of the whole set, not the shape of individual vectors.

Can this tool tell me if my vectors are linearly independent?

Indirectly, by watching what happens at each step. If a vector's leftover is zero, it was a combination of the earlier vectors and is dropped, so the output has fewer vectors than the input. In 2D that means all entered vectors lie on a single line; in 3D it means they lie in a line or a plane rather than filling the space.

References and verification

The example and behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools