How to use the Gram–Schmidt process to find an orthonormal basis

Gram–Schmidt keeps the span of a basis while turning its vectors into perpendicular unit vectors. At each step, we subtract the parts that point along the directions we already have. Then we divide by the remaining vector’s length.

Normalize the first vector

q1=v1‖v1‖

Remove the first direction from the second vector

w2=v2-(v2·q1)q1q2=w2‖w2‖

For the next vector, subtract its projections onto both earlier unit vectors before normalizing. Continue this way through an independent basis.

Apply the process to a basis for a plane

Let v1=(1,2,0) and v2=(-2,1,-5). The first length is 5, so q1=15(1,2,0). Here v2·q1=0, so w2=v2. Its length is 30, giving

q2=130(-2,1,-5)

These unit vectors are perpendicular and span the same plane as the original pair.

See a nonzero projection being removed

For v1=(1,0) and v2=(1,1), the first unit vector is q1=(1,0). The dot product v2·q1 is 1, so w2=(1,1)-(1,0)=(0,1). It already has length 1, giving q2=(0,1).