Gram-Schmidt calculator

The Gram-Schmidt process turns a set of independent vectors into an orthogonal set that spans the same space, the foundation of orthonormal bases, QR decomposition and least-squares fitting. This calculator runs the process on two vectors in three dimensions. You enter the first vector v1 and the second vector v2, each as three components. The tool keeps the first vector as it is, calling it u1, then removes from the second vector the part that points along u1, leaving a remainder u2 that is exactly perpendicular to u1. The amount removed is the projection coefficient, the dot product of v2 with u1 divided by the dot product of u1 with itself, multiplied by u1. The result is a pair of orthogonal vectors, which you can confirm by checking that their dot product is zero. Orthogonal sets are prized because they make many calculations simple and numerically stable. Enter your own two vectors to build an orthogonal basis, prepare a QR step or check an exercise. Every figure here is computed deterministically from the standard Gram-Schmidt formula, shown in full below with a worked example that reconciles exactly to the calculator so you can follow each step of the arithmetic.

Gram-Schmidt keeps u1 = v1 and sets u2 = v2 minus (v2 dot u1 / u1 dot u1) u1. For v1 = (1, 1, 0) and v2 = (1, 0, 1), the projection coefficient is 0.50 and the orthogonal vector is u2 = (0.50, -0.50, 1.00), with u1 dot u2 = 0.

Source: US National Institute of Standards and Technology (NIST). As at 25 June 2026.

u1 (unchanged)--
Projection coefficient--
Orthogonality check u1 . u2--
Orthogonal vector u2--

Gram-Schmidt orthogonalization

u1 = v1
coefficient k = ( v2 . u1 ) / ( u1 . u1 )
u2 = v2 - k u1
result: u1 and u2 are orthogonal, so u1 . u2 = 0
( . denotes the dot product )

The first vector is kept as the first orthogonal direction. The projection of the second vector onto that direction is the coefficient k times u1, and subtracting it leaves a remainder u2 perpendicular to u1. The two vectors then span the same plane but at right angles.

Worked example

Orthogonalize v1 = (1, 1, 0) and v2 = (1, 0, 1) with Gram-Schmidt.

  1. u1 = v1 = (1, 1, 0)
  2. v2 . u1 = (1)(1) + (0)(1) + (1)(0) = 1
  3. u1 . u1 = 1 + 1 + 0 = 2, so coefficient k = 1 / 2 = 0.5
  4. u2 = v2 - 0.5 u1 = (1 - 0.5, 0 - 0.5, 1 - 0) = (0.5, -0.5, 1)
  5. Check u1 . u2 = (1)(0.5) + (1)(-0.5) + (0)(1) = 0, confirmed orthogonal

The orthogonal vector is u2 = (0.50, -0.50, 1.00), perpendicular to u1. These are the calculator's default inputs, so the results above match the widget exactly.

Gram-Schmidt calculator: frequently asked questions

What is the Gram-Schmidt process?

The Gram-Schmidt process takes a list of linearly independent vectors and produces an orthogonal set spanning the same subspace. It works one vector at a time, subtracting from each new vector its projections onto the directions already fixed, so the leftover is perpendicular to all of them.

What is a projection coefficient?

The projection coefficient is how much of one vector lies along another. For vectors v2 and u1 it equals the dot product of v2 and u1 divided by the dot product of u1 with itself. Multiplying it by u1 gives the component of v2 in the u1 direction, which Gram-Schmidt removes.

How do I check the result is orthogonal?

Two vectors are orthogonal when their dot product is zero. After running Gram-Schmidt, take the dot product of u1 and u2; it should come out to zero, up to tiny rounding. This calculator reports that check so you can confirm the vectors are perpendicular.

Does this normalize the vectors?

This calculator produces an orthogonal set but does not scale them to unit length, so it stops short of a full orthonormal basis. To normalize, divide each vector by its own length. Leaving them unnormalized keeps the arithmetic exact and easy to follow.

Why is orthogonalization useful?

Orthogonal vectors decouple directions, which makes projections, least-squares fits and QR decompositions simple and numerically stable. Many algorithms in graphics, statistics and engineering rely on an orthogonal or orthonormal basis. The computation here is deterministic and reconciles exactly to the worked example.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 25 June 2026. See our methodology. This is general information, not financial, tax, legal or investment advice.