Gram-Schmidt Calculator

Apply the Gram-Schmidt process step by step

This calculator will orthonormalize the set of vectors, i.e. find the orthonormal basis, using the Gram-Schmidt process, with steps shown.

$$$\mathbf{\vec{v_{1}}}$$$ $$$\mathbf{\vec{v_{2}}}$$$ $$$\mathbf{\vec{v_{3}}}$$$

If the calculator did not compute something or you have identified an error, or you have a suggestion/feedback, please write it in the comments below.

Our Gram-Schmidt calculator serves as an essential companion for individuals delving into the complicated field of linear algebra. It makes the Gram-Schmidt process easy, whether you're dealing with a few vectors or a large set. Offering detailed, step-by-step solutions, it functions as your dedicated guide for the Gram-Schmidt process.

How to Use the Gram-Schmidt Calculator?

  • Input

    Enter your set of vectors into the provided fields. These vectors can be in two, three, or higher dimensions.

  • Calculation

    After inputting your vectors, click on the "Calculate" button. The calculator will instantly start processing your vectors.

  • Result

    The calculator will quickly generate the orthogonal and orthonormal basis for your set of vectors. Alongside the final result, it provides a detailed, step-by-step breakdown of the entire Gram-Schmidt process, ensuring you understand every part of it.

What Is the Gram-Schmidt Process?

The Gram-Schmidt process is a crucial method in linear algebra, serving to transform a set of vectors into an orthogonal and orthonormal basis. In layman's terms, it takes a set of vectors and converts them into a new set of vectors that are all perpendicular to each other. Additionally, the vectors are not only orthogonal but also of unit length, forming the orthonormal basis.

Let's consider a set of vectors $$$\left\{\mathbf{\vec{v_1}},\mathbf{\vec{v_2}},\ldots,\mathbf{\vec{v_n}}\right\}$$$ in a Euclidean space. The Gram-Schmidt process transforms this set into an orthogonal set $$$\left\{\mathbf{\vec{u_1}},\mathbf{\vec{u_2}},\ldots,\mathbf{\vec{u_n}}\right\}$$$ and orthonormal set $$$\left\{\mathbf{\vec{e_1}},\mathbf{\vec{e_2}},\ldots,\mathbf{\vec{e_n}}\right\}$$$ using the following steps:

Start by setting $$$\mathbf{\vec{u_1}}=\mathbf{\vec{v_1}}$$$.

For each subsequent vector $$$\mathbf{\vec{v_i}}$$$ $$$\left(i\gt1\right)$$$, subtract the projection of $$$\mathbf{\vec{v_i}}$$$ onto all preceding vectors $$$\mathbf{\vec{u_j}}$$$ $$$\left(j\lt i\right)$$$, and set this result as $$$\mathbf{\vec{u_i}}$$$. The projection of $$$\mathbf{\vec{v_i}}$$$ onto $$$\mathbf{\vec{u_j}}$$$ can be found using the formula:


where $$$\cdot$$$ denotes the dot product. Thus, the formula for $$$\mathbf{\vec{u_i}}$$$ becomes:


To obtain an orthonormal basis, normalize each vector $$$\mathbf{\vec{v_i}}$$$ by dividing it by its magnitude $$$\mathbf{\left\lvert\vec{u_i}\right\rvert}$$$.

This process forms the backbone for many mathematical and computational applications in diverse fields like physics, computer science, statistics, and machine learning. It's used in QR decomposition, in solving linear least squares problems, and in methods for solving eigenvalue problems, among other applications.

Consider the following simple example for a better understanding of the process:

Let's start with the vectors $$$\mathbf{\vec{v_1}}=\langle1,0\rangle$$$ and $$$\mathbf{\vec{v_2}}=\langle1,1\rangle$$$ in $$$\mathbb{R^n}$$$. The Gram-Schmidt process would proceed as follows:

Set $$$\mathbf{\vec{u_1}}=\mathbf{\vec{v_1}}=\langle1,0\rangle$$$.

Calculate $$$\mathbf{\vec{u_2}}=\mathbf{\vec{v_2}}-\operatorname{proj}_{\mathbf{\vec{u_1}}}\left(\mathbf{\vec{v_2}}\right)=\langle1,1\rangle-\frac{\langle1,1\rangle\cdot\langle1,0\rangle}{\langle1,0\rangle\cdot\langle1,0\rangle}\langle1,0\rangle=\langle1,1\rangle-\frac{1\cdot1+1\cdot0}{1\cdot1+0\cdot0}\langle1,0\rangle=\langle1,1\rangle-\langle1,0\rangle=\langle0,1\rangle$$$.

So the orthogonal basis for the vectors $$$\mathbf{\vec{v_1}}$$$ and $$$\mathbf{\vec{v_2}}$$$ is $$$\left\{\left[\begin{array}{c}1\\0\end{array}\right],\left[\begin{array}{c}0\\1\end{array}\right]\right\}$$$, which is also orthonormal as both vectors are of unit length.

What Does Orthogonal Mean?

In the context of vector algebra and geometry, two vectors are said to be orthogonal if they are perpendicular to each other. This condition is met when the dot product (or scalar product) of the two vectors is zero.

Mathematically, let's consider two vectors $$$\mathbf{\vec{u}}$$$ and $$$\mathbf{\vec{v}}$$$. If $$$\mathbf{\vec{u}}\cdot\mathbf{\vec{v}}=0$$$, where $$$\cdot$$$ represents the dot product, then $$$\mathbf{\vec{u}}$$$ and $$$\mathbf{\vec{v}}$$$ are orthogonal.

In linear algebra, when we talk about an "orthogonal set of vectors" or an "orthogonal basis," it means that all the vectors in the set are pairwise orthogonal, i.e., any pair of vectors in the set is orthogonal. This property is fundamental in many mathematical operations and transformations, including the Gram-Schmidt process.

Why Choose Our Gram-Schmidt Calculator?

  • Efficiency and Accuracy

    The calculator executes the Gram-Schmidt process swiftly, providing accurate results every time. This reduces the risk of computational errors that can occur with manual calculations.

  • Ease of Use

    The user interface is intuitive and straightforward. Simply input your vectors and let the calculator do the heavy lifting.

  • Step-by-Step Solutions

    The calculator not only generates the orthogonal and orthonormal basis but also provides step-by-step solutions. This allows you to follow and understand the process in detail.

  • Versatility

    It can handle many vectors. Whether you have two vectors in a two-dimensional space or three five-dimensional vectors, our calculator is equipped to handle them.


Can I apply Gram-Schmidt to linearly dependent vectors?

Technically, you can apply the Gram-Schmidt process to linearly dependent vectors. However, the process will stop yielding useful results as soon as it encounters a zero vector after orthogonalizing with respect to a preceding dependent vector. In other words, the Gram-Schmidt process can help you discover linear dependency in a set of vectors, but it won't be able to produce a full basis if the original vectors are not linearly independent.

Can the Gram-Schmidt Calculator handle vectors of any dimension?

Our calculator can handle many vectors. Whether you're working with vectors in two dimensions or vectors in higher-dimensional spaces, our calculator is capable of computing an orthogonal and orthonormal basis.

What is Gram-Schmidt orthogonalization?

Gram-Schmidt orthogonalization is a method in linear algebra used to convert a set of vectors into an orthogonal and orthonormal basis. It works by iteratively making each vector perpendicular to the preceding ones. Each orthogonalized vector is also normalized to obtain the orthonormal basis.