Skip to content

Gram-Schmidt 3D

The Gram-Schmidt process turns three vectors v⃗1,v⃗2,v⃗3\vec v_1,\vec v_2,\vec v_3 in R3\mathbb{R}^3, generally not orthogonal to each other, into an orthonormal basis u⃗1,u⃗2,u⃗3\vec u_1,\vec u_2,\vec u_3. The tips of the vectors can be dragged in “Edit v₁ v₂ v₃” mode; the view rotates by dragging the background.

1.00×
v₁, v₂, v₃ = —u₁, u₂, u₃ = —‖u₁‖, ‖u₂‖, ‖u₃‖ = —u₁·u₂, u₁·u₃, u₂·u₃ = —

Step 1. The first unit vector is obtained by normalizing v⃗1\vec v_1, i.e. dividing it by its own norm:

u⃗1=v⃗1∥v⃗1∥\vec u_1=\dfrac{\vec v_1}{\lVert \vec v_1\rVert}

Step 2. The component of v⃗2\vec v_2 along u⃗1\vec u_1 (its projection onto u⃗1\vec u_1) is subtracted, leaving the orthogonal part w⃗2\vec w_2; w⃗2\vec w_2 is then normalized:

w⃗2=v⃗2−(v⃗2⋅u⃗1) u⃗1,u⃗2=w⃗2∥w⃗2∥\vec w_2=\vec v_2-(\vec v_2\cdot\vec u_1)\,\vec u_1,\qquad \vec u_2=\dfrac{\vec w_2}{\lVert \vec w_2\rVert}

Step 3. Both projections are subtracted from v⃗3\vec v_3, onto u⃗1\vec u_1 and onto u⃗2\vec u_2; the remaining orthogonal part w⃗3\vec w_3 is then normalized:

w⃗3=v⃗3−(v⃗3⋅u⃗1) u⃗1−(v⃗3⋅u⃗2) u⃗2,u⃗3=w⃗3∥w⃗3∥\vec w_3=\vec v_3-(\vec v_3\cdot\vec u_1)\,\vec u_1-(\vec v_3\cdot\vec u_2)\,\vec u_2,\qquad \vec u_3=\dfrac{\vec w_3}{\lVert \vec w_3\rVert}

Pressing “Compute & keep” animates this sequence on the simulator, color by color, in the same order described above. The “slow motion” slider allows following it at a gentler pace, without changing the final result.

Below the simulator’s buttons, four numeric rows are always kept up to date:

  • the coordinates of the starting vectors v⃗1,v⃗2,v⃗3\vec v_1,\vec v_2,\vec v_3 (also editable by typing them directly, in “Edit v₁ v₂ v₃” mode);
  • the coordinates of the resulting unit vectors u⃗1,u⃗2,u⃗3\vec u_1,\vec u_2,\vec u_3, which appear one at a time during “Compute & keep”, in sync with the animation;
  • the norms ∥u⃗1∥,∥u⃗2∥,∥u⃗3∥\lVert\vec u_1\rVert,\lVert\vec u_2\rVert,\lVert\vec u_3\rVert, which should stay at 11 (the resulting vectors are unit vectors);
  • the cross dot products u⃗1⋅u⃗2, u⃗1⋅u⃗3, u⃗2⋅u⃗3\vec u_1\cdot\vec u_2,\ \vec u_1\cdot\vec u_3,\ \vec u_2\cdot\vec u_3, which should stay at 00 (the resulting vectors are pairwise orthogonal).

Unit norms together with zero dot products are exactly the definition of an orthonormal basis: those live numbers offer a way to check, for any linearly independent starting triple, that the process worked correctly.