Visual linear algebra

Geometric routes to QR factorization

Gram-Schmidt orthogonalization, Givens rotations, Householder reflections and Direct Rotations applied to the same matrices

Gram-Schmidt

Reshape the columns of A into an orthonormal frame, then compute R from QᵀA

Givens rotations

Rotate coordinate planes so entries below the diagonal are eliminated one at a time

Householder reflections

Reflect across hyperplanes so a whole column tail is eliminated in one step

Direct Rotations

Use one proper rotation in a plane tailored to the active column and its target axis

One matrix, one goal, four constructions

QR factorization decomposes a matrix into the product A = QR, where Q has orthonormal columns and R is upper triangular.

Why is this decomposition important? Two central applications are:

  1. Computing eigenvalues. In the QR algorithm, repeated QR factorizations produce a sequence of matrices similar to A. Under suitable conditions, this sequence approaches an upper-triangular form whose diagonal entries are the eigenvalues of A.

  2. Solving linear systems and least-squares problems. To solve Ax = b, we write QRx = b and multiply by QT:

    Rx = QTb.

    Because R is upper triangular, the resulting system can be solved efficiently by back substitution. When the original system is inconsistent, the same procedure produces a least-squares solution.

    Orthogonal transformations preserve lengths and are numerically well conditioned. In particular, QR methods solve least-squares problems without forming ATA, which can magnify numerical errors.

But there is more than one geometric route from A to its QR factorization. Gram–Schmidt reshapes the columns of A into an orthonormal basis. Givens rotations eliminate entries one at a time. Householder reflections eliminate a whole column tail at once. Direct Rotations also eliminate a whole column tail at once, using one proper rotation in a plane tailored to the active column and its target axis. The animations below show how these four geometric constructions arrive at the same algebraic destination.

The 3D comparison uses two shared examples for all four constructions: one full-rank matrix and one flat rank-deficient matrix. Use the video controls to play, pause or scrub each animation; the links below the videos open them in a new tab

First, the idea in 2D

In two dimensions, the three distinct motions are almost minimal, which makes them easiest to compare. Gram-Schmidt reshapes the two columns into an orthonormal pair. Givens rotations and Householder reflections instead move A into triangular position by an orthogonal transformation. In 2D, the Direct Rotation step is the same single plane rotation as the Givens step. Their difference appears only in higher dimensions, where Givens uses coordinate planes while Direct Rotations uses one plane tailored to the active column and its target axis.

One detail worth noticing: Gram-Schmidt, in its standard form, produces non-negative diagonal entries in R. The orthogonal-transformation constructions may produce different signs depending on their rotation, reflection or target-axis choices.

Gram-Schmidt in 2D

The two columns are orthogonalized and normalized to form Q directly.

Column orthogonalization in the plane
Open video in a new tab

Givens rotation in 2D

A single rotation places the first column on the horizontal axis, eliminating the lower-left entry.

Triangularization by rotation in the plane
Open video in a new tab

Householder reflection in 2D

A single reflection places the first column on the horizontal axis in one orthogonal step.

Triangularization by reflection in the plane
Open video in a new tab

Full-rank 3D example

In the full-rank case, the original parallelepiped has nonzero volume and the four constructions produce an upper triangular R with three nonzero diagonal entries

Gram-Schmidt orthogonalization

Projection subtraction and scaling reshape the columns of A into the orthonormal columns of Q

A is transformed into Q, and R is computed as QᵀA
Open video in a new tab

Givens rotations

Successive rotations in coordinate planes reorient the figure so selected entries below the diagonal become zero

A is transformed into R by accumulated coordinate-plane rotations
Open video in a new tab

Householder reflections

Successive reflections across hyperplanes reorient the figure so whole column tails below pivots become zero

A is transformed into R by accumulated hyperplane reflections
Open video in a new tab

Direct Rotations

One proper rotation per active column acts in the plane determined by that column and its target axis, eliminating the whole column tail at once

A is transformed into R by accumulated direct plane rotations
Open video in a new tab

Flat rank-deficient 3D example

In the flat case, the columns of A lie in a lower-dimensional shape. QR still separates orthogonal directions from triangular coordinates, but the final diagonal reveals the missing dimension

Gram-Schmidt orthogonalization

The residual direction can become zero after projections remove the part already explained by previous directions

The flat shape leaves a zero residual direction
Open video in a new tab

Givens rotations

Coordinate-plane rotations place the flat shape into triangular position while preserving lengths and angles

The flat shape is rotated into place
Open video in a new tab

Householder reflections

Hyperplane reflections place the same flat shape into triangular position by larger orthogonal steps

The flat shape is reflected into place
Open video in a new tab

Direct Rotations

One tailored proper rotation per active column preserves the lower-dimensional shape while placing it into triangular position

The flat shape is rotated into place one active column at a time
Open video in a new tab

Visual summary

This visual summary emphasizes the central split Q ← A → R for the three constructions shown in the image. Direct Rotations joins Givens and Householder on the A → R side, using proper rotations rather than reflections

Visual summary of Gram-Schmidt orthogonalization, Givens rotations and Householder reflections for QR factorization
Three-route visual summary: Gram-Schmidt builds Q; Givens and Householder transform A into R

Comparison of the four constructions

The comparison table below summarizes where the four routes agree and where their geometric and computational behavior differs.

Question Gram–Schmidt orthogonalization Givens rotation Householder reflection Direct rotation
Transforms A into Q R R R
Remaining factor computed as R = QTA Q = (Gk ··· G1)−1 Q = (Hk ··· H1)−1 Q = (Uk ··· U1)−1
Algebraic step operation right-multiplication by
column scaling and shear matrices
left-multiplication by
coordinate-plane rotation matrices
left-multiplication by
reflection matrices
left-multiplication by
plane rotation matrices
Geometric step operation • subtracts projections
onto previous orthonormal directions
• normalizes
the remaining component
rotates
in a coordinate plane
reflects
across a hyperplane
rotates in the plane spanned
by the active column
and its target axis
Rank-deficient A:
geometric behavior
dependent column

zero residual;
Q and R are reduced
• lower-dimensional shape
rotated into place;
• full-size R has one or more
zeros on the diagonal
• lower-dimensional shape
reflected into place;
• full-size R has one or more
zeros on the diagonal
• lower-dimensional shape
rotated into place;
• full-size R has one or more
zeros on the diagonal
Sign of diagonal entries R positive after redundant columns are discarded convention-dependent convention-dependent convention-dependent
Dimensions used here
for A(m×n, rank r)
• Q is m×r
• R is r×n
• Q is m×m
• R is m×n
• Q is m×m
• R is m×n
• Q is m×m
• R is m×n
Numerical stability classical form can lose
orthogonality near dependence
stable stable same as Householder
in numerical tests
Typical computational use incremental construction
of orthonormal bases
sparse or structured A;
QR updates
standard choice
for dense QR
geometric interpretation;
not standard in software

The displayed factorizations retain the signs produced by each construction. Multiplying a column of Q and the corresponding row of R by −1 gives an equivalent QR factorization, so the diagonal signs need not match unless a sign convention is imposed.

Direct Rotations are closely aligned with Householder QR: with the corresponding sign adjustment, the two steps produce the same active trailing matrix, although one uses a proper rotation and the other a reflection.

Takeaway

This is a revealing example of geometric reasoning solving an algebraic problem. The same QR decomposition can be constructed through four different geometric routes: orthogonalization, coordinate-plane rotations, hyperplane reflections, and direct plane rotations. In the full-rank cases, their final factorizations agree up to sign choices in the corresponding columns of Q and rows of R.

The closest relationship is also not immediately obvious. Householder reflection and Direct Rotation begin from different geometric ideas, yet they produce nearly identical sequences of intermediate matrices, differing only by signs.