---
title: Gram-Schmidt Orthogonalisation
url: https://www.emergentmind.com/topics/gram-schmidt-orthogonalisation
type: topic
---

# Gram-Schmidt Orthogonalisation

Gram–Schmidt orthogonalisation is a procedure for transforming a linearly independent family of vectors into an orthogonal or orthonormal family spanning the same subspace and, in matrix form, for producing QR factorizations such as \(A=QR\) or \(X=QR\), where \(Q\) has orthonormal columns and \(R\) is upper triangular [1108.4209]. In current research, the topic extends well beyond the classical columnwise construction to block, reorthogonalized, low-synchronization, randomized, mixed-precision, and non-Euclidean variants, as well as applications in Krylov methods, ultra-high dimensional regression, signal processing, and \(p\)-adic lattices [2408.10109][2111.14641][2507.04668][2305.07886].

## 1. Classical construction and QR factorization

For a matrix \(A=[a_1,\dots,a_m]\in\mathbb{R}^{n\times m}\) with linearly independent columns, Gram–Schmidt constructs orthonormal vectors \(Q=[q_1,\dots,q_m]\in\mathbb{R}^{n\times m}\) and an upper triangular matrix \(R\in\mathbb{R}^{m\times m}\) such that
\[
A=QR,\qquad Q^TQ=I.
\]
The geometric core is the orthogonal projection of a new column \(a_j\) onto the orthogonal complement of the span of the previous basis vectors:
\[
\widetilde q_j=(I-Q_{j-1}Q_{j-1}^T)a_j,\qquad q_j=\frac{\widetilde q_j}{\|\widetilde q_j\|_2},
\]
with
\[
r_{1:j-1,j}=Q_{j-1}^Ta_j,\qquad r_{jj}=\|\widetilde q_j\|_2.
\]
Equivalently,
\[
a_j = Q_{j-1}r_{1:j-1,j}+q_j r_{jj}.
\]
These formulas appear in classical, block, and randomized treatments alike [2111.14641].

The columnwise recurrence is commonly written as
\[
r_{ij}=q_i^Ta_j,\qquad i=1,\dots,j-1,
\]
\[
v_j=a_j-\sum_{i=1}^{j-1}q_i r_{ij},
\]
\[
r_{jj}=\|v_j\|_2,\qquad q_j=\frac{v_j}{r_{jj}}.
\]
In modified Gram–Schmidt (MGS), the same orthogonalization is performed sequentially on the progressively deflated vector:
\[
v_j \leftarrow v_j - q_i(q_i^Tv_j),
\]
which changes the floating-point behaviour while preserving equivalence in exact arithmetic [2405.01298].

A block formulation replaces vectors by blocks \(X_k\in\mathbb{R}^{m\times s}\) in a partition
\[
X=[X_1,\dots,X_p]\in\mathbb{R}^{m\times ps}.
\]
At block step \(k\), one computes
\[
R_{1:k-1,k}=Q_{k-1}^T X_k,\qquad [Q_k,R_{kk}] = IO\!\left(X_k-Q_{k-1}R_{1:k-1,k}\right),
\]
where \(IO\) is an intraorthogonalization routine such as HouseQR, TSQR, or CholQR [2405.01298]. A related project-and-normalize formulation writes
\[
\begin{bmatrix}Q & X\end{bmatrix}
=
\begin{bmatrix}Q & U\end{bmatrix}
\begin{bmatrix}I & P\\ 0 & N\end{bmatrix},
\]
which recasts orthogonalization as a QR problem on an augmented matrix and underlies several communication-aware algorithms [2204.13393].

## 2. Loss of orthogonality and the role of reorthogonalization

In floating-point arithmetic, Gram–Schmidt is assessed not only by the residual of the QR factorization but also by the quality of orthogonality. For block methods, the loss of orthogonality is measured by
\[
\|I-Q^TQ\|,
\]
or equivalently \(\|Q^TQ-I\|\). Two further stability measures are
\[
\frac{\|X-QR\|}{\|X\|},\qquad
\frac{\|R^TR-X^TX\|}{\|X\|^2},
\]
the latter being the relative Cholesky residual [2408.10109].

The standard numerical distinction is that classical Gram–Schmidt computes all inner products against the original vector \(a_j\), whereas modified Gram–Schmidt interleaves projection and deflation. The cited analyses state that CGS can suffer severe loss of orthogonality, especially for ill-conditioned matrices, while MGS is typically more stable; reorthogonalization, by running the inner loop twice, often yields still better orthogonality and leads to variants such as CGS2 or MGS2 [2111.14641].

The reorthogonalized block classical Gram–Schmidt algorithm proposed by Barlow and Smoktunowicz factorizes a full column rank matrix \(A\) into \(A=QR\) and, with appropriate assumptions on the diagonal blocks of \(R\), produces factors satisfying
\[
\|I-Q^TQ\|_2=O(\varepsilon)
\]
and
\[
\|A-QR\|_2=O(\varepsilon\|A\|_2),
\]
where \(\varepsilon\) is machine unit roundoff [1108.4209]. The same source emphasizes that the second projection pass removes the remaining numerical contamination from previously computed subspaces.

A related analysis for symmetric saddle point problems states that \(\mathrm{BCGS2}\), implemented with Householder QR, is backward stable under a mild assumption on the matrix \(M\): the computed vector \(\tilde z\) is the exact solution to a slightly perturbed linear system \(Mz=f\) [1312.5277]. In the single-column case \(s=1\), later block analyses simplify dramatically because \(\kappa(X_k)=1\) for the intraorthogonalization subproblems; the resulting corollary proves that DCGS2 and CGS-2 are as stable as Householder QR in the sense of unit-roundoff orthogonality [2408.10109].

## 3. Block orthogonalisation, synchronization, and high-performance variants

Modern high-performance work treats Gram–Schmidt as a communication problem as much as an arithmetic one. The abstract framework used for block classical Gram–Schmidt separates each block step into a projection stage and an intraorthogonalization stage:
\[
G=\operatorname{Proj}(X_k,Q_{k-1}),\qquad [Q_k,R_{kk}] = \operatorname{QR}(G).
\]
The computed projection is modeled as
\[
\bar G = G+\Delta G,\qquad \|\Delta G\|\le \epsilon_{\text{proj}}\|X_k\|,
\]
and the computed intraorthogonalization as
\[
\bar G+\Delta\bar G = Q_kR_{kk},\qquad \|\Delta\bar G\|\le \epsilon_{\text{qr}}\|\bar G\|,
\]
together with an orthogonality guarantee
\[
\|I-Q_k^TQ_k\|\le \eta.
\]
This reduction allows the stability of an entire block method to be expressed in terms of projection error, QR backward error, and conditioning of the projected block [2408.10109].

A central result of that analysis is that a “strong” intrablock orthogonalization routine is only needed for the very first block. In the variant called BCGS-A,
\[
[Q_1,R_{11}] = \mathrm{IO}(X_1),
\]
and for \(k=2,\dots,p\),
\[
R_{1:k-1,k}=Q_{k-1}^TX_k,\qquad
[Q_k,R_{kk}] = \mathrm{IO}\!\left(X_k-Q_{k-1}R_{1:k-1,k}\right).
\]
If the first block is orthogonalized by a Householder-like routine and later blocks use a weaker but still backward stable routine, then the entire basis achieves orthogonality at the level of roundoff under the stated conditioning assumptions [2408.10109].

The same paper studies low-synchronization variants obtained from a 4-sync reorthogonalized baseline, BCGSI+A, by removing synchronization points one at a time. The resulting 3-sync, 2-sync, and 1-sync variants have progressively weaker stability guarantees, and the analysis shows that “stability begins to degrade with the first reduction of synchronization points.” The variant requiring only one synchronization per block column “cannot be guaranteed to be stable in practice,” whereas the single-column analogues remain unit-roundoff stable [2408.10109].

| Variant | Synchronizations per block | Bound on \(\|I-Q^TQ\|\) |
|---|---:|---:|
| BCGSI+A | 4 | \(O(u)\) |
| BCGSI+A-3S | 3 | \(O(u)\,\kappa(X)^{\max\{\alpha,1\}}\) |
| BCGSI+A-2S | 2 | \(O(u)\,\kappa(X)^2\) |
| BCGSI+A-1S | 1 | \(O(u)\,\kappa(X)^2\) |

A parallel development concerns the “Pythagorean” block variant BCGS-PIP, based on the identity
\[
X_k^TX_k = R_{1:k-1,k}^TR_{1:k-1,k}+R_{kk}^TR_{kk},
\]
with
\[
R_{kk}=\operatorname{chol}\!\left(P_k-R_{1:k-1,k}^TR_{1:k-1,k}\right),\qquad P_k=X_k^TX_k.
\]
For BCGS-PIP, the loss of orthogonality is bounded by \(O(\varepsilon)\kappa^2(X)\) provided \(O(\varepsilon)\kappa^2(X)<1\). Two reorthogonalized variants, BCGS-PIP+ and BCGS-PIPI+, improve this to an \(O(\varepsilon)\) bound while retaining asymptotically two synchronization points per block column [2405.01298].

A hardware-aware formulation integrates these ideas into the project-and-normalize QR view. It leads to BCGS-PIP, BCGS-PIP+, and TSPQR, and the performance model combines a Roofline model for intra-node work with a LogP-style model for inter-node communication. The framework’s practical principle is to combine different orthogonalization algorithms across hardware levels, for example Householder or TSPQR locally and BCGS-PIP+ for reductions [2204.13393].

## 4. Randomized and sketched Gram–Schmidt processes

Randomized Gram–Schmidt replaces exact Euclidean inner products by sketched inner products. With a sketching matrix
\[
S\in\mathbb{R}^{k\times n},\qquad k\ll n,
\]
or \(\Omega\in\mathbb{R}^{k\times n}\), one uses
\[
\langle x,y\rangle_\Omega=\langle \Omega x,\Omega y\rangle_2
\]
as an approximate surrogate for \(\langle x,y\rangle\). If the sketch is an \(\varepsilon\)-embedding for a subspace \(V\), then for all \(x,y\in V\),
\[
\big|\langle x,y\rangle-\langle Sx,Sy\rangle\big|\le \varepsilon \|x\|\,\|y\|.
\]
The single-vector randomized Gram–Schmidt (RGS) orthogonalizes a new vector \(a_j\) by solving a small sketched least-squares problem:
\[
p_j=\Omega a_j,\qquad S_{j-1}=\Omega Q_{j-1},
\]
\[
r_{1:j-1,j}=\arg\min_y \|S_{j-1}y-p_j\|_2,
\]
\[
q'_j=a_j-Q_{j-1}r_{1:j-1,j},\qquad q_j=\frac{q'_j}{\|q'_j\|_2}.
\]
The stated motivation is that the expensive operations remain in the original \(n\)-space, while the coefficient computation is performed in a much smaller \(k\)-space [2011.05090].

The block generalization, RBGS, partitions
\[
W=[W_{(1)},\dots,W_{(p)}]\in\mathbb{R}^{n\times m}
\]
and computes
\[
R_{(1:i-1,i)}=\arg\min_Y \|S_{(1:i-1)}Y-P_{(i)}\|_F,
\]
\[
Q'_{(i)} = W_{(i)}-Q_{(1:i-1)}R_{(1:i-1,i)},
\]
followed by a block QR factorization
\[
Q'_{(i)} = Q_{(i)}R_{(i,i)}.
\]
A low-synchronization RBGS variant can be implemented in parallel “using only one global reduction operation between processors per block,” with the sketched update
\[
S'_{(i)} = P_{(i)}-S_{(1:i-1)}R_{(1:i-1,i)}.
\]
The same work applies RBGS to block Arnoldi, randomized GMRES, randomized FOM, and randomized Rayleigh–Ritz methods [2111.14641].

These randomized formulations are presented as numerically robust alternatives to deterministic Gram–Schmidt. The cited analyses state that RGS can be less computationally expensive than the classical Gram–Schmidt process while being at least as numerically stable as modified Gram–Schmidt, and that stability conditions depend on the reduced dimension \(m\) and \(\kappa(W)\), but not directly on the ambient dimension \(n\) [2011.05090][2111.14641].

## 5. Generalized inner products and alternative algebraic settings

A substantial generalization concerns non-standard inner products induced by a symmetric positive definite matrix \(A\). In that setting, the thin QR factorization is
\[
Z=QR,\qquad Q^TAQ=I_n,
\]
with inner product
\[
\langle x,y\rangle_A=x^TAy,\qquad \|x\|_A=\sqrt{x^TAx}.
\]
Straightforward MGS implementations require \(2n\) matrix-vector multiplications with respect to \(A\), but the paper “Efficient implementations of the modified Gram-Schmidt orthogonalization with a non-standard inner product” proposes high-accuracy and high-performance \(n\)-MV implementations. The key observation is that every \(r_{ij}\) can be formed using vectors in the ranges of \(Z\) and \(AZ\), so the expensive action of \(A\) can be reduced to a single pass over the columns [1703.10440].

Beyond real and complex Euclidean spaces, the paper “On \(p\)-adic Gram-Schmidt Orthogonalization Process” formulates orthogonality using a norm \(N\) on a finite-dimensional vector space over \(\mathbb{Q}_p\). A decomposition
\[
V=V_1\oplus\cdots\oplus V_n
\]
into one-dimensional subspaces is \(N\)-orthogonal if
\[
N(u_1+\cdots+u_n)=\max_i N(u_i),\qquad u_i\in V_i.
\]
The construction is algorithmic rather than projection-based: finding a vector orthogonal to a hyperplane is reduced to a closest vector problem in a \(p\)-adic lattice, and the resulting algorithms are linked to cryptography based on \(p\)-adic lattices [2305.07886].

Another nonstandard construction is “dimensional lifting through generalized Gram-Schmidt process.” Here an ordered family \(\{e_1,\dots,e_k\}\subset V\) is embedded into a higher-dimensional space \(W=\mathbb{F}^{n+k}\) by appending carefully chosen extra coordinates so that the lifted vectors become mutually orthogonal. In one convenient representation,
\[
f_i=(e_i,x_{i,1},x_{i,2},\dots,x_{i,i-1},1,0,\dots,0),
\]
with the coefficients determined recursively from the orthogonality conditions \(\langle f_i,f_j\rangle=0\). The construction is order-dependent and non-unitary, and it allows orthogonalization even for linearly dependent vectors, repeated vectors, and zero vectors [1606.03873].

## 6. Applications and related constructions

In ultra-high dimensional linear regression, Gram–Schmidt orthogonalization appears as the mechanism behind Gram-Schmidt Forward Regression (GSFR). With centered data, the method orthogonalizes each candidate predictor against the span of the already selected variables and evaluates the standardized unique-contribution score
\[
\hat{\mu}_{J,i} =
\frac{
n^{-1}\sum_{t=1}^n (y_t-\hat y_{t;J})\,\hat x_{ti;J}^{\perp}
}{
\left(n^{-1}\sum_{t=1}^n (y_t-\hat y_{t;J})^2\right)^{1/2}
\left(n^{-1}\sum_{t=1}^n (\hat x_{ti;J}^{\perp})^2\right)^{1/2}
}.
\]
At each stage,
\[
\hat j_{k+1} = \arg\max_{1\le j\le p} |\hat\mu_{\hat J_k,j}|.
\]
The paper states that GSFR is theoretically equivalent to forward regression except for the stopping rule, improves computational efficiency, and in ultra-high dimensional settings achieves a convergence rate comparable to OGA while ensuring variable selection consistency under mild conditions [2507.04668].

In the theory of orthogonal polynomials, Gram–Schmidt applied to monomials with weighted \(L^2\) inner products yields classical Hermite, Laguerre, and Jacobi systems. For example, with
\[
(f,g)=\int_a^b f(x)g(x)w(x)\,dx
\]
and starting basis \(v_0(x)=1,v_1(x)=x,\dots\), the paper derives determinant formulas for the orthogonalized polynomials through generalized Vandermonde determinants with Gamma and Beta function entries. It also presents a geometric formulation via the Hodge star operator, where the orthogonal complement can be expressed through exterior algebra [2106.06408].

A different application concerns approximation of orthogonalization itself. For a full column rank matrix
\[
{\bf A}=[{\bf a}_1,\dots,{\bf a}_k]\in\mathbb{R}^{n\times k},
\]
with column-normalized version
\[
\bar{\bf A}=\left[\frac{{\bf a}_1}{\|{\bf a}_1\|},\dots,\frac{{\bf a}_k}{\|{\bf a}_k\|}\right],
\]
the orthonormalized matrix \({\bf V}\) obtained by Gram–Schmidt satisfies
\[
{\bf V}-\bar{\bf A}=\bar{\bf A}\bar{\bf U},
\qquad
\bar{\bf R}=\bar{\bf A}^T\bar{\bf A}-{\bf I}.
\]
The cited analysis shows that if \(\bar{\bf A}\) is close to orthonormal, then \({\bf V}-\bar{\bf A}\) is small; this is used to explain why a high dimensional Gaussian matrix can approximate the corresponding truncated Haar matrix, and it is connected to compressed subspace clustering and random projections [1701.00711].

Across these settings, the persistent theme is unchanged: Gram–Schmidt orthogonalisation is the mechanism by which a spanning family is replaced by one whose geometry is structured by orthogonality. What varies is the ambient algebra, the error model, the communication pattern, and the downstream task—whether QR factorization in floating-point arithmetic, Krylov basis generation, variable selection, polynomial construction, or lattice computation.

Source: https://www.emergentmind.com/topics/gram-schmidt-orthogonalisation