Gram-Schmidt Orthonormalization Calculator
List your vectors and get the orthogonal basis in exact fractions, the orthonormal basis in square-root form, each projection step and the matching QR factorization.
S'executa al teu navegador. Els fitxers mai no surten del dispositiu. Mira com comprovar-ho
…
Com es fa
- 1Enter the vectors
Type one vector per row in the grid or text box.
- 2Choose the options
Pick classical or modified order and optional weights.
- 3Read the bases
See the orthogonal vectors and the orthonormal surds.
- 4Follow the projections
Check each coefficient and subtraction in the steps list.
- 5Look at QR
Compare Q and R for the matrix of your vectors.
- 6Save
Copy the bases, download decimals as CSV, or print.
Sobre aquesta eina
The Gram-Schmidt process takes a list of vectors and produces perpendicular vectors that span the same space. It is the idea behind orthonormal bases, QR factorization, orthogonal polynomials and the projections used in least squares, and it is a favourite exam question because every step can be checked. The trouble is the arithmetic. Each new vector has to lose its projection onto every earlier one, the coefficients are ratios of dot products, and normalizing brings in square roots, so a hand calculation quickly fills with expressions like 1/√6. Decimal calculators hide the structure: 0.4082 means nothing to a marker who expects √6/6. This calculator keeps the orthogonal vectors as exact fractions and writes each orthonormal vector as an exact surd such as (−√3/3, √3/3, √3/3). For every vector it prints the formula u = v − (⟨v, u1⟩/⟨u1, u1⟩)·u1 − …, the value of each coefficient, the squared length and the normalizing factor. If a vector depends on the ones before it, the remainder is the zero vector; the tool says so and skips it, which tells you the dimension of the span. You can switch to the modified order, add positive weights for a weighted inner product, and see the QR factors of the matrix whose columns are your vectors.
What each line means
Take the vectors in the order given. The first orthogonal vector is the first input. For each later vector v, the tool computes the inner product of v with every earlier orthogonal vector u, divides by ⟨u, u⟩ to get the coefficient, and subtracts coefficient times u. What is left is orthogonal to all earlier vectors. Dividing it by the square root of its own inner product gives a unit vector. The Gram matrix check at the end confirms that every cross inner product is exactly zero.
Classical or modified
Classical Gram-Schmidt projects the original v onto each earlier u. Modified Gram-Schmidt subtracts one projection at a time and uses the partly reduced vector for the next inner product. In floating point the modified order loses much less orthogonality, which is why numerical texts prefer it; in exact arithmetic both give the same vectors, and the tool lets you see that.
Weighted inner products
Enter weights w1, …, wn to use ⟨x, y⟩ = Σ wi·xi·yi. This is how orthogonality is defined in weighted least squares and in many statistics and physics problems. Weights must be positive.
The QR link
Put the vectors in the columns of a matrix A. The orthonormal vectors form Q, and R holds the coefficients: entry (j, k) is ⟨qj, ak⟩ and the diagonal holds the lengths. The tool shows both, in square-root form, with the largest error of QR − A.
Worked example
Enter (1, 1, 0), (1, 0, 1) and (0, 1, 1). Then u1 = (1, 1, 0) with ⟨u1, u1⟩ = 2. Next u2 = v2 − (1/2)·u1 = (1/2, −1/2, 1) with ⟨u2, u2⟩ = 3/2. Last, u3 = v3 − (1/2)·u1 − (1/3)·u2 = (−2/3, 2/3, 2/3) with ⟨u3, u3⟩ = 4/3. Normalizing gives e1 = (√2/2, √2/2, 0), e2 = (√6/6, −√6/6, √6/3) and e3 = (−√3/3, √3/3, √3/3). Every pairwise inner product of the u vectors is 0, and the R factor has diagonal √2, √6/2 and 2√3/3.
Limits
Up to ten vectors with up to ten entries each are supported. The order of the input vectors changes the basis you get, though not the space it spans. The tool works with numbers only, not with functions or symbolic entries, so polynomial inner products are not computed here.
Exemple resolt
(1, 1, 0), (1, 0, 1), (0, 1, 1) → u2 = (1/2, −1/2, 1), u3 = (−2/3, 2/3, 2/3), e3 = (−√3/3, √3/3, √3/3).
En resum
- Categoria: Matemàtiques i ciència
- S'executa al navegador, sense registre, sense pujar res.
- La informació que introdueixes es queda al dispositiu.
- Disponible en anglès.
- Contingut revisat per última vegada:
- Font oficial: Classical and modified Gram-Schmidt (Trefethen and Bau, Numerical Linear Algebra, lectures 7–8)
Preguntes freqüents
What is the difference between orthogonal and orthonormal?
Orthogonal vectors are perpendicular to each other. Orthonormal vectors are orthogonal and also have length 1. The tool lists both: first the exact orthogonal set, then each one divided by its length.
What happens if my vectors are dependent?
A dependent vector reduces to the zero vector, so it adds nothing new. The tool marks it as skipped, continues with the next vector, and reports the dimension of the span.
Why do my answers have different signs or scales?
Orthogonal vectors can be rescaled and stay orthogonal, so books often clear fractions. Orthonormal vectors are fixed up to sign once the input order is fixed; different input orders give different bases.
Is modified Gram-Schmidt different?
Only in how rounding errors behave on a computer. With exact fractions both versions give identical vectors; the steps differ only in which inner products are shown.
Can I use a weighted inner product?
Yes. Type one positive weight per coordinate. Orthogonality and lengths are then measured with those weights, and the check uses the same inner product.
How does this give a QR factorization?
With the vectors as the columns of A, Q holds the orthonormal vectors and R the projection coefficients and lengths. The QR panel shows both and confirms that QR equals A.
