Skip to content

Gram-Schmidt 3D

The Gram-Schmidt process turns three vectors v1,v2,v3\vec v_1,\vec v_2,\vec v_3 in R3\mathbb{R}^3, generally not orthogonal to each other, into an orthonormal basis u1,u2,u3\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 v1\vec v_1, i.e. dividing it by its own norm:

u1=v1v1\vec u_1=\dfrac{\vec v_1}{\lVert \vec v_1\rVert}

Step 2. The component of v2\vec v_2 along u1\vec u_1 (its projection onto u1\vec u_1) is subtracted, leaving the orthogonal part w2\vec w_2; w2\vec w_2 is then normalized:

w2=v2(v2u1)u1,u2=w2w2\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 v3\vec v_3, onto u1\vec u_1 and onto u2\vec u_2; the remaining orthogonal part w3\vec w_3 is then normalized:

w3=v3(v3u1)u1(v3u2)u2,u3=w3w3\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 v1,v2,v3\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 u1,u2,u3\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 u1,u2,u3\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 u1u2, u1u3, u2u3\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.