Back

Gram-Schmidt orthogonalization in 2D

What you are seeing: two input vectors v1,v2v_1, v_2 and the orthonormal output u1,u2u_1, u_2 produced by one step of Gram-Schmidt: u1=v1/v1u_1 = v_1/|v_1|, then u2=(v2v2,u1u1)/v2v2,u1u1u_2 = (v_2 - \langle v_2, u_1\rangle u_1) / |v_2 - \langle v_2, u_1\rangle u_1|. The dashed cyan vector shows the projection v2,u1u1\langle v_2, u_1\rangle u_1 being subtracted; the orange vector is the residual that becomes u2u_2 after normalization.

Drag the sliders for the angles and magnitudes of v1v_1 and v2v_2. The readout reports u1,u2|\langle u_1, u_2\rangle|, which stays at machine zero (101610^{-16}) regardless of input. Pushing v2v_2 collinear with v1v_1 collapses the residual to zero (linearly dependent inputs), which the readout flags.

Figure 1. Gram-Schmidt orthogonalization in 2D. Method: modified Gram-Schmidt, closed-form.
v1 angle20
v1 length2.00
v2 angle70
v2 length2.00

WHAT TO TRY

  • Vary each control and watch the rail readouts respond.
  • Compare the diagnostic plot against the live scene.