Also known as Gram–Schmidt process, Gram-Schmidt orthonormalization, Gram–Schmidt orthonormalization
In mathematics, particularly linear algebra and numerical analysis, the Gram–Schmidt process or Gram-Schmidt algorithm is a way of finding a set of two or more vectors that are perpendicular to each other.
Article
In mathematics, particularly linear algebra and numerical analysis, the Gram–Schmidt process or Gram-Schmidt algorithm is a way of finding a set of two or more vectors that are perpendicular to each other.
By technical definition, it is a method of constructing an orthonormal basis from a set of vectors in an inner product space, most commonly the Euclidean space
R
n
{\displaystyle \mathbb {R} ^{n}}
equipped with the standard inner product. The Gram–Schmidt process takes a finite, linearly independent set of vectors
The method is named after Jørgen Pedersen Gram and Erhard Schmidt, but Pierre-Simon Laplace had been familiar with it before Gram and Schmidt. In the theory of Lie group decompositions, it is generalized by the Iwasawa decomposition.
The application of the Gram–Schmidt process to the column vectors of a full column rank matrix yields the QR decomposition (it is decomposed into an orthogonal and a triangular matrix).
When this process is implemented on a computer, the vectors
u
k
{\displaystyle \mathbf {u} _{k}}
are often not quite orthogonal, due to rounding errors. For the Gram–Schmidt process as described above (sometimes referred to as "classical Gram–Schmidt") this loss of orthogonality is particularly bad; therefore, it is said that the (classical) Gram–Schmidt process is numerically unstable.
The Gram–Schmidt process can be stabilized by a small modification; this version is sometimes referred to as modified Gram-Schmidt or MGS. This approach gives the same result as the original formula in exact arithmetic and introduces smaller errors in finite-precision arithmetic.
Instead of computing the vector uk as
u
k
=
v
k
−
proj
u
1
(
v
k
)
−
proj
u
2
Algorithm
The following MATLAB algorithm implements classical Gram–Schmidt orthonormalization. The vectors v1, ..., vk (columns of matrix V, so that V(:,j) is the
j
{\displaystyle j}
th vector) are replaced by orthonormal vectors (columns of U) which span the same subspace.
The cost of this algorithm is asymptotically O(nk2) floating point operations, where n is the dimensionality of the vectors.
Via Gaussian elimination
If the rows {v1, ..., vk} are written as a matrix
A
{\displaystyle A}
, then applying Gaussian elimination to the augmented matrix
[
A
A
T
|
A
]
{\displaystyle \left[AA^{\mathsf {T}}|A\right]}
will produce the orthogonalized vectors in place of
A
{\displaystyle A}
. However the matrix
A
A
T
{\displaystyle AA^{\mathsf {T}}}
must be brought to row echelon form, using only the row operation of adding a scalar multiple of one row to another. For example, taking
v
1
=
[
3
1
]
Determinant formula
The result of the Gram–Schmidt process may be expressed in a non-recursive formula using determinants.
e
j
=
1
D
j
−
1
D
j
|
⟨
v
1
,
v
1
⟩
⟨
v
2
,
v
1
⟩
⋯
⟨
v
j
,
v
1
⟩
⟨
v
Expressed using geometric algebra
Expressed using notation used in geometric algebra, the unnormalized results of the Gram–Schmidt process can be expressed as
operator defined above. The results can equivalently be expressed as
Alternatives
Other orthogonalization algorithms use Householder transformations or Givens rotations. The algorithms using Householder transformations are more stable than the stabilized Gram–Schmidt process. On the other hand, the Gram–Schmidt process produces the
j
{\displaystyle j}
th orthogonalized vector after the
j
{\displaystyle j}
th iteration, while orthogonalization using Householder reflections produces all the vectors only at the end. This makes only the Gram–Schmidt process applicable for iterative methods like the Arnoldi iteration.
Yet another alternative is motivated by the use of Cholesky decomposition for inverting the matrix of the normal equations in linear least squares. Let
V
{\displaystyle V}
be a full column rank matrix, whose columns need to be orthogonalized. The matrix
V
∗
V
{\displaystyle V^{*}V}
is Hermitian and positive definite, so it can be written as
V
∗
V
=
L
L
Run-time complexity
Gram-Schmidt orthogonalization can be done in strongly-polynomial time. The run-time analysis is similar to that of Gaussian elimination.
Article from Wikipedia (CC BY-SA 4.0), where it is maintained by volunteer editors.
and this projection, guaranteed to be orthogonal to all of the vectors in the subspace
U
{\displaystyle U}
.
The Gram–Schmidt process also applies to a linearly independent countably infinite sequence {vi}i. The result is an orthogonal (or orthonormal) sequence {ui}i such that for natural number n: the algebraic span of
. If an orthonormal basis is to be produced, then the algorithm should test for zero vectors in the output and discard them because no multiple of a zero vector can have a length of 1. The number of vectors output by the algorithm will then be the dimension of the space spanned by the original inputs.
A variant of the Gram–Schmidt process using transfinite recursion applied to a (possibly uncountably) infinite sequence of vectors
. In particular, when applied to a (algebraic) basis of a Hilbert space (or, more generally, a basis of any dense subspace), it yields a (functional-analytic) orthonormal basis. Note that in the general case often the strict inequality
κ
<
λ
{\displaystyle \kappa <\lambda }
holds, even if the starting set was linearly independent, and the span of
is a "formal" determinant, i.e. the matrix contains both scalars and vectors; the meaning of this expression is defined to be the result of a cofactor expansion along the row of vectors.
The determinant formula for the Gram-Schmidt is computationally (exponentially) slower than the recursive algorithms described above; it is mainly of theoretical interest.
which is closely related to the expression using determinants above.
∗
,
{\displaystyle V^{*}V=LL^{*},}
using the Cholesky decomposition. The lower triangular matrix
L
{\displaystyle L}
with strictly positive diagonal entries is invertible. Then columns of the matrix
U
=
V
(
L
−
1
)
∗
{\displaystyle U=V\left(L^{-1}\right)^{*}}
are orthonormal and span the same subspace as the columns of the original matrix
V
{\displaystyle V}
. The explicit use of the product
V
∗
V
{\displaystyle V^{*}V}
makes the algorithm unstable, especially if the product's condition number is large. Nevertheless, this algorithm is used in practice and implemented in some software packages because of its high efficiency and simplicity.
In quantum mechanics there are several orthogonalization schemes with characteristics better suited for certain applications than original Gram–Schmidt. Nevertheless, it remains a popular and effective algorithm for even the largest electronic structure calculations.