Skip to main content

Gram Schmidt Calculator

Our free linear algebra calculator solves gram schmidt problems. Get worked examples, visual aids, and downloadable results.

Skip to calculator
Mathematics

Gram Schmidt Calculator

Apply the Gram-Schmidt orthogonalization process to three 3D vectors. Find orthogonal and orthonormal bases with step-by-step projection calculations.

Last updated: December 2025Reviewed by NovaCalculator Mathematics Team

Calculator

Adjust values & calculate
v1
v2
v3
Orthogonal Vectors Found
3
Orthogonality verified
Orthogonal Basis (unnormalized)
u1[1, 1, 0]||u1|| = 1.414214
u2[0.5, -0.5, 1]||u2|| = 1.224745
u3[-0.666667, 0.666667, 0.666667]||u3|| = 1.154701
Orthonormal Basis (normalized)
e1[0.707107, 0.707107, 0]
e2[0.408248, -0.408248, 0.816497]
e3[-0.57735, 0.57735, 0.57735]

Step-by-Step Process

Step 1: u1 = v1
Orthogonal: [1, 1, 0] | Normalized: [0.707107, 0.707107, 0]
Step 2: u2 = v2 - proj(v2, u1)
Orthogonal: [0.5, -0.5, 1] | Normalized: [0.408248, -0.408248, 0.816497]
Step 3: u3 = v3 - proj(v3, u1) - proj(v3, u2)
Orthogonal: [-0.666667, 0.666667, 0.666667] | Normalized: [-0.57735, 0.57735, 0.57735]
Summary: All three vectors are linearly independent. The orthonormal basis spans all of R3.
Your Result
3 orthogonal vectors found | Full rank: Yes | Orthogonality verified: Yes
Share Your Result
Understand the Math

Formula

u_k = v_k - sum_{j=1}^{k-1} proj(v_k, u_j), where proj(v, u) = (v dot u)/(u dot u) * u

Each vector u_k is obtained by subtracting from v_k its projections onto all previously computed orthogonal vectors u_1, ..., u_{k-1}. The result is perpendicular to all previous vectors. Normalizing gives orthonormal vectors e_k = u_k / ||u_k||.

Last reviewed: December 2025

Worked Examples

Example 1: Orthogonalizing Three 3D Vectors

Apply Gram-Schmidt to v1 = [1, 1, 0], v2 = [1, 0, 1], v3 = [0, 1, 1].
Solution:
u1 = v1 = [1, 1, 0], ||u1|| = sqrt(2) e1 = [1/sqrt(2), 1/sqrt(2), 0] proj(v2, u1) = (1+0+0)/(1+1+0) = 1/2 u2 = [1, 0, 1] - (1/2)[1, 1, 0] = [1/2, -1/2, 1], ||u2|| = sqrt(3/2) e2 = [1/sqrt(6), -1/sqrt(6), 2/sqrt(6)] proj(v3, u1) = (0+1+0)/2 = 1/2, proj(v3, u2) = (0-1/2+1)/(3/2) = 1/3 u3 = [0,1,1] - (1/2)[1,1,0] - (1/3)[1/2,-1/2,1] = [-2/3, 2/3, 2/3] e3 = [-1/sqrt(3), 1/sqrt(3), 1/sqrt(3)]
Result: Orthonormal basis: e1 = [0.707, 0.707, 0], e2 = [0.408, -0.408, 0.816], e3 = [-0.577, 0.577, 0.577]

Example 2: Detecting Linear Dependence

Apply Gram-Schmidt to v1 = [1, 2, 3], v2 = [2, 4, 6], v3 = [1, 0, 1].
Solution:
u1 = v1 = [1, 2, 3], ||u1|| = sqrt(14) proj(v2, u1) = (2+8+18)/14 = 28/14 = 2 u2 = [2, 4, 6] - 2*[1, 2, 3] = [0, 0, 0] v2 is linearly dependent on v1 (it is exactly 2*v1). u3 = v3 - proj(v3, u1) = [1,0,1] - (1+0+3)/14 * [1,2,3] = [1-2/7, -4/7, 1-6/7]
Result: Only 2 independent vectors found (rank = 2). v2 = 2*v1 is dependent.
Expert Insights

Background & Theory

The Gram Schmidt Calculator applies the following established principles and formulas. Mathematics rests on a hierarchy of number systems, each extending the previous. The natural numbers (1, 2, 3, ...) support counting and ordering. The integers add negative values and zero, enabling subtraction without restriction. The rational numbers, expressible as p/q where p and q are integers and q is nonzero, close the system under division. The real numbers fill the gaps left by irrationals such as the square root of 2 or pi, forming a complete ordered field. The complex numbers, written as a + bi where i is the square root of negative one, complete the algebraic closure of the reals and allow every polynomial to have a root. Prime factorization states that every integer greater than one is uniquely expressible as a product of primes, a result known as the Fundamental Theorem of Arithmetic. Computing the greatest common divisor (GCD) of two integers relies most efficiently on the Euclidean algorithm: repeatedly replace the larger number with the remainder when it is divided by the smaller, until the remainder is zero. The last nonzero remainder is the GCD. The least common multiple (LCM) follows from the identity LCM(a, b) = |a * b| / GCD(a, b). Modular arithmetic defines equivalence classes of integers that share the same remainder under division by a modulus n. Fermat's Little Theorem and Euler's Theorem arise from this structure and underpin modern cryptography. Logarithms are the inverses of exponential functions. If b raised to the power x equals y, then the logarithm base b of y equals x. The natural logarithm uses base e, approximately 2.71828. Combinatorics counts arrangements and selections. The number of ordered arrangements (permutations) of r objects from n distinct objects is nPr = n! / (n - r)!. The number of unordered selections (combinations) is nCr = n! / (r! * (n - r)!). Pascal's triangle arranges these binomial coefficients so that each entry equals the sum of the two entries directly above it. The Fibonacci sequence, defined by F(1) = 1, F(2) = 1, and F(n) = F(n-1) + F(n-2), appears throughout nature and connects deeply to the golden ratio via Binet's formula.

History

The history behind the Gram Schmidt Calculator traces back through the following developments. Mathematics as a systematic discipline traces to ancient Mesopotamia. Babylonian clay tablets dating to around 1800 BCE demonstrate knowledge of quadratic equations, Pythagorean triples, and base-60 arithmetic, suggesting a practical mathematical tradition far preceding Greek formalism. Euclid of Alexandria compiled the Elements around 300 BCE, establishing the axiomatic method that would define rigorous mathematics for over two thousand years. His work organized plane geometry, number theory, and proportion into logically chained propositions derived from a small set of postulates. The algorithm bearing his name for computing GCDs appears in Book VII and remains in use today. In the 9th century, the Persian scholar Muhammad ibn Musa Al-Khwarizmi wrote Al-Kitab al-mukhtasar fi hisab al-jabr wal-muqabala, the treatise whose title gave algebra its name. He systematized the solution of linear and quadratic equations and described procedures that operated on unknowns as objects, a conceptual leap away from purely numerical calculation. Rene Descartes introduced coordinate geometry in 1637 by uniting algebra and Euclidean geometry, allowing curves to be studied through equations. This synthesis set the stage for calculus. Isaac Newton and Gottfried Wilhelm Leibniz independently developed calculus during the 1660s and 1670s, triggering a priority dispute that lasted decades and divided British and Continental mathematicians. Carl Friedrich Gauss proved the Fundamental Theorem of Algebra in 1799, showing that every nonconstant polynomial has at least one complex root. His Disquisitiones Arithmeticae of 1801 established modern number theory. David Hilbert's formalist program at the turn of the 20th century sought to place all of mathematics on an explicit axiomatic foundation, a project that Kurt Godel's incompleteness theorems of 1931 showed to be fundamentally limited. Alan Turing's work in the 1930s on computability introduced the theoretical model of the stored-program computer and linked mathematical logic directly to the limits of algorithmic calculation. His proof that no algorithm can decide in general whether an arbitrary program will halt or run forever placed fundamental boundaries on what mathematics can mechanically determine, and it opened the discipline now known as theoretical computer science.

Share this calculator

Explore More

Frequently Asked Questions

The Gram-Schmidt process is an algorithm that takes a set of linearly independent vectors and produces a set of orthogonal (or orthonormal) vectors that span the same subspace. It works by iteratively subtracting the projections of each new vector onto all previously computed orthogonal vectors. The result is a set of mutually perpendicular vectors that are much easier to work with in computations. The process is named after Jorgen Pedersen Gram and Erhard Schmidt, though the concept predates them. It is a cornerstone of numerical linear algebra and is used in QR decomposition, least squares problems, and signal processing.
The Gram-Schmidt process starts with the first vector unchanged: u1 = v1. For the second vector, subtract its projection onto u1: u2 = v2 - proj(v2, u1), where proj(v2, u1) = (v2 dot u1)/(u1 dot u1) * u1. For the third vector, subtract projections onto both u1 and u2: u3 = v3 - proj(v3, u1) - proj(v3, u2). This continues for each additional vector. After computing each orthogonal vector, normalize it by dividing by its length to get an orthonormal vector. The projection subtraction removes the component parallel to each previous vector, leaving only the perpendicular component.
The QR decomposition factors a matrix A into Q (an orthogonal or unitary matrix) and R (an upper triangular matrix) such that A = QR. The Gram-Schmidt process directly computes the QR decomposition: the orthonormal vectors become the columns of Q, and R is formed from the projection coefficients. Specifically, R_ij = (v_j dot e_i) for i <= j and R_ij = 0 for i > j. QR decomposition is crucial for solving least squares problems, computing eigenvalues (QR algorithm), and providing numerically stable solutions to linear systems. It is one of the most important matrix factorizations in numerical computing.
The modified Gram-Schmidt (MGS) process rearranges the order of computations to improve numerical stability. In classical Gram-Schmidt, all projections for a vector are computed using the original orthogonal vectors. In MGS, after computing each projection and subtracting it, the vector is immediately updated before computing the next projection. This seemingly minor change significantly reduces the accumulation of rounding errors. Classical Gram-Schmidt can produce vectors that are far from orthogonal in floating-point arithmetic, while MGS maintains much better orthogonality. For practical numerical computation, MGS or Householder reflections are strongly preferred over classical Gram-Schmidt.
A projection of vector v onto vector u, written proj(v, u), is the component of v that lies along the direction of u. The formula is proj(v, u) = (v dot u)/(u dot u) * u. Geometrically, it is the shadow of v cast onto the line defined by u. The scalar coefficient (v dot u)/(u dot u) tells you how many copies of u make up this shadow. In Gram-Schmidt, subtracting the projection removes the component of the new vector that is parallel to a previously computed orthogonal vector, leaving only the perpendicular component. This is why the resulting vectors are guaranteed to be orthogonal to each other.
The Gram-Schmidt process has wide applications across mathematics and engineering. In signal processing, it creates orthogonal filter banks for efficient signal decomposition. In statistics, it orthogonalizes predictor variables in regression to diagnose multicollinearity. In quantum mechanics, it constructs orthonormal basis states from general state vectors. In computer graphics, it re-orthogonalizes rotation matrices that drift due to numerical errors. In communications engineering, it designs orthogonal codes for CDMA systems. In numerical methods, it is the foundation of the Arnoldi and Lanczos algorithms for computing eigenvalues of large sparse matrices.
Educational Note: This calculator is provided for educational and informational purposes. Results are based on the formulas and inputs provided. Always verify important calculations independently. NovaCalculator processes calculator inputs client-side; optional analytics follow visitor consent settings.Reviewed by: NovaCalculator Mathematics Team โ€” Verified against standard mathematical and scientific references. Last reviewed: December 2025. ยฉ 2024โ€“2026 NovaCalculator.

Share this calculator

Formula

u_k = v_k - sum_{j=1}^{k-1} proj(v_k, u_j), where proj(v, u) = (v dot u)/(u dot u) * u

Each vector u_k is obtained by subtracting from v_k its projections onto all previously computed orthogonal vectors u_1, ..., u_{k-1}. The result is perpendicular to all previous vectors. Normalizing gives orthonormal vectors e_k = u_k / ||u_k||.

Worked Examples

Example 1: Orthogonalizing Three 3D Vectors

Problem: Apply Gram-Schmidt to v1 = [1, 1, 0], v2 = [1, 0, 1], v3 = [0, 1, 1].

Solution: u1 = v1 = [1, 1, 0], ||u1|| = sqrt(2)\ne1 = [1/sqrt(2), 1/sqrt(2), 0]\n\nproj(v2, u1) = (1+0+0)/(1+1+0) = 1/2\nu2 = [1, 0, 1] - (1/2)[1, 1, 0] = [1/2, -1/2, 1], ||u2|| = sqrt(3/2)\ne2 = [1/sqrt(6), -1/sqrt(6), 2/sqrt(6)]\n\nproj(v3, u1) = (0+1+0)/2 = 1/2, proj(v3, u2) = (0-1/2+1)/(3/2) = 1/3\nu3 = [0,1,1] - (1/2)[1,1,0] - (1/3)[1/2,-1/2,1] = [-2/3, 2/3, 2/3]\ne3 = [-1/sqrt(3), 1/sqrt(3), 1/sqrt(3)]

Result: Orthonormal basis: e1 = [0.707, 0.707, 0], e2 = [0.408, -0.408, 0.816], e3 = [-0.577, 0.577, 0.577]

Example 2: Detecting Linear Dependence

Problem: Apply Gram-Schmidt to v1 = [1, 2, 3], v2 = [2, 4, 6], v3 = [1, 0, 1].

Solution: u1 = v1 = [1, 2, 3], ||u1|| = sqrt(14)\n\nproj(v2, u1) = (2+8+18)/14 = 28/14 = 2\nu2 = [2, 4, 6] - 2*[1, 2, 3] = [0, 0, 0]\nv2 is linearly dependent on v1 (it is exactly 2*v1).\n\nu3 = v3 - proj(v3, u1) = [1,0,1] - (1+0+3)/14 * [1,2,3] = [1-2/7, -4/7, 1-6/7]

Result: Only 2 independent vectors found (rank = 2). v2 = 2*v1 is dependent.

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 a set of orthogonal (or orthonormal) vectors that span the same subspace. It works by iteratively subtracting the projections of each new vector onto all previously computed orthogonal vectors. The result is a set of mutually perpendicular vectors that are much easier to work with in computations. The process is named after Jorgen Pedersen Gram and Erhard Schmidt, though the concept predates them. It is a cornerstone of numerical linear algebra and is used in QR decomposition, least squares problems, and signal processing.

How does the Gram-Schmidt process work step by step?

The Gram-Schmidt process starts with the first vector unchanged: u1 = v1. For the second vector, subtract its projection onto u1: u2 = v2 - proj(v2, u1), where proj(v2, u1) = (v2 dot u1)/(u1 dot u1) * u1. For the third vector, subtract projections onto both u1 and u2: u3 = v3 - proj(v3, u1) - proj(v3, u2). This continues for each additional vector. After computing each orthogonal vector, normalize it by dividing by its length to get an orthonormal vector. The projection subtraction removes the component parallel to each previous vector, leaving only the perpendicular component.

What is the QR decomposition and how does Gram-Schmidt relate to it?

The QR decomposition factors a matrix A into Q (an orthogonal or unitary matrix) and R (an upper triangular matrix) such that A = QR. The Gram-Schmidt process directly computes the QR decomposition: the orthonormal vectors become the columns of Q, and R is formed from the projection coefficients. Specifically, R_ij = (v_j dot e_i) for i <= j and R_ij = 0 for i > j. QR decomposition is crucial for solving least squares problems, computing eigenvalues (QR algorithm), and providing numerically stable solutions to linear systems. It is one of the most important matrix factorizations in numerical computing.

What is the modified Gram-Schmidt process and why is it preferred?

The modified Gram-Schmidt (MGS) process rearranges the order of computations to improve numerical stability. In classical Gram-Schmidt, all projections for a vector are computed using the original orthogonal vectors. In MGS, after computing each projection and subtracting it, the vector is immediately updated before computing the next projection. This seemingly minor change significantly reduces the accumulation of rounding errors. Classical Gram-Schmidt can produce vectors that are far from orthogonal in floating-point arithmetic, while MGS maintains much better orthogonality. For practical numerical computation, MGS or Householder reflections are strongly preferred over classical Gram-Schmidt.

What is a projection in the context of Gram-Schmidt?

A projection of vector v onto vector u, written proj(v, u), is the component of v that lies along the direction of u. The formula is proj(v, u) = (v dot u)/(u dot u) * u. Geometrically, it is the shadow of v cast onto the line defined by u. The scalar coefficient (v dot u)/(u dot u) tells you how many copies of u make up this shadow. In Gram-Schmidt, subtracting the projection removes the component of the new vector that is parallel to a previously computed orthogonal vector, leaving only the perpendicular component. This is why the resulting vectors are guaranteed to be orthogonal to each other.

What are the applications of the Gram-Schmidt process?

The Gram-Schmidt process has wide applications across mathematics and engineering. In signal processing, it creates orthogonal filter banks for efficient signal decomposition. In statistics, it orthogonalizes predictor variables in regression to diagnose multicollinearity. In quantum mechanics, it constructs orthonormal basis states from general state vectors. In computer graphics, it re-orthogonalizes rotation matrices that drift due to numerical errors. In communications engineering, it designs orthogonal codes for CDMA systems. In numerical methods, it is the foundation of the Arnoldi and Lanczos algorithms for computing eigenvalues of large sparse matrices.

References

Reviewed by Manoj Kumar, Mathematics Educator ยท Editorial policy