Gram Schmidt Calculator
Orthonormalize a set of linearly independent vectors using the Gram-Schmidt process. Get step-by-step projections, orthogonal and orthonormal bases, and interactive vector visualization.
What is the Gram-Schmidt Process?
The Gram-Schmidt process is an algorithm for orthonormalizing a set of linearly independent vectors in an inner product space. Given a set of vectors $\{v_1, v_2, \dots, v_k\}$ that span a subspace, the Gram-Schmidt process produces an orthogonal (or orthonormal) basis $\{u_1, u_2, \dots, u_k\}$ for the same subspace.
The Algorithm
Starting with a set of linearly independent vectors $\{v_1, v_2, \dots, v_k\}$ in $\mathbb{R}^n$, the Gram-Schmidt process computes:
$$u_1 = v_1$$ $$u_2 = v_2 - \frac{\langle v_2, u_1 \rangle}{\langle u_1, u_1 \rangle} u_1$$ $$u_3 = v_3 - \frac{\langle v_3, u_1 \rangle}{\langle u_1, u_1 \rangle} u_1 - \frac{\langle v_3, u_2 \rangle}{\langle u_2, u_2 \rangle} u_2$$And in general:
$$u_k = v_k - \sum_{i=1}^{k-1} \frac{\langle v_k, u_i \rangle}{\langle u_i, u_i \rangle} u_i$$After computing the orthogonal basis $\{u_1, \dots, u_k\}$, the orthonormal basis is obtained by normalizing each vector:
$$e_k = \frac{u_k}{\|u_k\|}$$Explore more vector and matrix operations with the Matrix Inverse Calculator and Matrix Multiply Calculator.
Key Properties
- The orthogonal basis $\{u_1, \dots, u_k\}$ spans the same subspace as the original vectors $\{v_1, \dots, v_k\}$.
- Each $u_k$ is orthogonal to all previous $u_i$ vectors: $\langle u_k, u_i \rangle = 0$ for $i < k$.
- The orthonormal basis $\{e_1, \dots, e_k\}$ has unit length: $\|e_k\| = 1$ for all $k$.
- If the input vectors are not linearly independent, the process will produce a zero vector at some step.
How to Use This Calculator
- Choose the dimension — Select the dimension of the vector space $\mathbb{R}^n$ (2 to 5).
- Choose the number of vectors — The number of vectors must not exceed the dimension.
- Enter the vectors — Type each vector as comma-separated values (e.g., "1,2,3" for a 3D vector).
- View the results — The orthogonal and orthonormal bases are computed instantly with step-by-step details.
Applications
The Gram-Schmidt process is fundamental in linear algebra and has numerous applications: computing QR decompositions for solving linear systems, constructing orthonormal bases for function spaces (Legendre polynomials, Chebyshev polynomials), signal processing and data compression, Google's PageRank algorithm, and dimensionality reduction techniques like PCA. For related linear algebra tools, try the Eigenvalue Eigenvector Calculator or Matrix Determinant Calculator.
Frequently Asked Questions
What is the Gram-Schmidt process?
The Gram-Schmidt process is an algorithm that takes a set of linearly independent vectors and produces an orthogonal (or orthonormal) basis for the same subspace. It works by sequentially projecting each vector onto the subspace spanned by the previous vectors and subtracting those projections.
What is the difference between orthogonal and orthonormal?
An orthogonal basis consists of vectors that are all mutually perpendicular (dot product equals zero between any two distinct vectors). An orthonormal basis is an orthogonal basis where each vector has unit length (norm equal to 1). Orthonormal bases are particularly useful because they preserve lengths and angles when changing coordinates.
Why do the input vectors need to be linearly independent?
The Gram-Schmidt process requires linearly independent input because if a vector is a linear combination of previous vectors, the projection will equal the vector itself, resulting in a zero vector after subtraction. This means the output set would not be a basis (it would have fewer non-zero vectors than the original set).
What happens if I enter more vectors than the dimension?
If you enter more vectors than the dimension of the space, the vectors are guaranteed to be linearly dependent (since you cannot have more than $n$ linearly independent vectors in $\mathbb{R}^n$). The Gram-Schmidt process will produce zero vectors, and the result will not be a valid basis.
What is the QR decomposition?
The Gram-Schmidt process is directly related to the QR decomposition of a matrix, where $A = QR$. Here, $Q$ is an orthogonal matrix whose columns are the orthonormal vectors produced by Gram-Schmidt, and $R$ is an upper triangular matrix containing the projection coefficients. QR decomposition is widely used for solving linear least squares problems and eigenvalue algorithms.
Can Gram-Schmidt be applied to function spaces?
Yes! The Gram-Schmidt process can be applied to any inner product space, including function spaces. For example, applying Gram-Schmidt to the monomials $\{1, x, x^2, x^3, \dots\}$ on the interval $[-1, 1]$ with the $L^2$ inner product produces the Legendre polynomials, which are orthogonal basis functions used extensively in physics and engineering.