BYTETOOLS

Gram-Schmidt Calculator

Turn any set of vectors into an orthogonal or orthonormal basis with the modified Gram-Schmidt process, showing every projection subtraction as a step.

3
Input vectors
3
Basis size
0
Dropped (dependent)
5.8e-10
max |eᵢ·eⱼ|

Orthonormal basis

e1 = (0.707107, 0.707107, 0)

e2 = (0.408248, -0.408248, 0.816497)

e3 = (-0.57735, 0.57735, 0.57735)

Every pair of these vectors is perpendicular — the largest dot product between two different basis vectors is 5.77e-10, which is floating-point noise.

Step by step

v1 = (1, 1, 0)

Nothing to subtract — this is the first kept vector.

u = (1, 1, 0), ‖u‖ = 1.414214 → e = (0.707107, 0.707107, 0)

v2 = (1, 0, 1)

  • − ((v2·u1) / (u1·u1)) u1 = − (0.5) · (1, 1, 0)

u = (0.5, -0.5, 1), ‖u‖ = 1.224745 → e = (0.408248, -0.408248, 0.816497)

v3 = (0, 1, 1)

  • − ((v3·u1) / (u1·u1)) u1 = − (0.5) · (1, 1, 0)
  • − ((v3·u2) / (u2·u2)) u2 = − (0.333333) · (0.5, -0.5, 1)

u = (-0.6667, 0.6667, 0.6667), ‖u‖ = 1.154701 → e = (-0.57735, 0.57735, 0.57735)

This is the modified Gram-Schmidt process: each projection is subtracted from the running vector rather than all at once from the original, which loses far less precision in floating point.

What is the Gram-Schmidt Calculator?

The ByteTools Gram-Schmidt Calculator converts a list of vectors into an orthogonal basis — and optionally normalises it to an orthonormal one — by repeatedly subtracting projections.

  • Modified Gram-Schmidt for better floating-point accuracy than the classical form
  • Toggle between an orthogonal basis and a normalised orthonormal one
  • Every projection subtraction shown as an individual step
  • Linearly dependent vectors detected and dropped instead of causing a divide-by-zero
  • Verification tile showing the largest dot product between different basis vectors
  • Handles up to 8 vectors of up to 8 components, entirely in your browser

How to use the Gram-Schmidt Calculator

  1. 1

    Enter one vector per line, with components separated by spaces or commas.

  2. 2

    Leave 'Normalise to unit length' ticked for an orthonormal basis, or untick it to see the orthogonal vectors before scaling.

  3. 3

    Read the resulting basis, and check the max dot-product tile confirming the vectors really are perpendicular.

  4. 4

    Expand the step-by-step panel to see each projection that was subtracted.

  5. 5

    Copy the basis with the copy button.

About the Gram-Schmidt Calculator

The ByteTools Gram-Schmidt Calculator converts a list of vectors into an orthogonal basis — and optionally normalises it to an orthonormal one — by repeatedly subtracting projections. For each vector it removes the component lying along every basis vector already found, using uₖ = vₖ − Σ ((vₖ·uᵢ)/(uᵢ·uᵢ))uᵢ, then divides by the length to get a unit vector.

It uses the modified form of the algorithm, where each projection is subtracted from the running vector rather than all at once from the original. The two are algebraically identical but the modified version loses far less precision in floating point. Every subtraction is printed as its own line so you can follow — or check — the working step by step.

If a vector collapses to zero it means that vector was already in the span of the earlier ones, so the tool drops it and says so explicitly rather than dividing by zero. All computation happens in your browser; nothing is uploaded and nothing is stored.

Frequently asked questions

What does the Gram-Schmidt process do?

It takes a set of vectors that span a subspace and produces a new set spanning exactly the same subspace, but with every pair at right angles. Normalising each result to length 1 makes the set orthonormal, which turns many later calculations into simple dot products.

What is the difference between classical and modified Gram-Schmidt?

Classical subtracts all projections of the original vector at once; modified subtracts each projection from the partially updated vector. They give the same answer in exact arithmetic, but the modified version is significantly more accurate in floating point, so this calculator uses it.

What happens if my vectors are linearly dependent?

A dependent vector has no component outside the span of the earlier ones, so subtracting the projections leaves the zero vector. There is no way to normalise that, so the tool drops the vector and tells you it was dependent — which doubles as a dependency test.

Does the order of the vectors matter?

Yes. The first vector keeps its direction exactly, and each later one is adjusted against those before it, so reordering the input gives a different — but equally valid — orthonormal basis for the same subspace.

What is an orthonormal basis good for?

With an orthonormal basis, the coefficients of any vector are just its dot products with the basis vectors, no linear system needed. That underpins projections, least-squares fitting, Fourier analysis and the Q in QR decomposition.

Related tools