Ad Space — Top Banner

Gram-Schmidt Orthogonalization Calculator

Orthogonalize two 2D vectors using the Gram-Schmidt process.
Find the orthogonal pair and the orthonormal basis, with verification of perpendicularity.

Orthogonal Basis

The Gram-Schmidt process converts any set of linearly independent vectors into a set of mutually perpendicular (orthogonal) vectors that span the same space. Orthonormal bases — orthogonal with unit length — are fundamental to linear algebra, numerical methods, and quantum mechanics.

The process for two vectors u1 and u2:

Step 1: v1 = u1 (keep the first vector)

Step 2: v2 = u2 - (u2 · v1 / |v1|²) v1

The second term is the projection of u2 onto v1. Subtracting it removes the component of u2 that lies along v1, leaving only the perpendicular component.

Verify orthogonality: v1 · v2 = 0 (the dot product should be zero, or near zero accounting for floating-point rounding).

Normalize to get the orthonormal basis:

e1 = v1 / |v1| e2 = v2 / |v2|

Why it matters. QR decomposition in numerical linear algebra uses Gram-Schmidt (or a numerically stable variant). Orthonormal bases simplify projections dramatically — the projection of any vector onto an orthonormal basis vector is just their dot product. In quantum mechanics, states are represented as vectors in a Hilbert space, and the basis states must be orthonormal.

The classic instability note: repeated Gram-Schmidt on many vectors accumulates floating-point errors. For large problems, modified Gram-Schmidt or Householder reflections are preferred. For two or three vectors as here, classic Gram-Schmidt is perfectly adequate.


Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.