linalg::orthog --
orthogonalization of vectors
Introductionlinalg::orthog(S) orthogonalizes the
vectors in S using the Gram-Schmidt orthogonalization
algorithm.
Call(s)linalg::orthog(S)
ParametersS |
- | a set or list of vectors of the same dimension (a
vector is an n x 1 or 1 x n matrix of a domain of
category Cat::Matrix) |
Returnsa set or a list of vectors, respectively.
Related
Functionslinalg::factorQR,
linalg::isUnitary,
linalg::normalize,
linalg::scalarProduct,
lllint, norm
DetailsS are orthogonalized with respect to
the scalar product linalg::scalarProduct.S,
and they are pairwise orthogonal, i.e.: v * w = 0 for all
v, w in O with v <> w.map(O, linalg::normalize).S should be
a list.S must be defined over the same
component ring.S must be a
field, i.e., a domain of category Cat::Field.
Example
1The following list of vectors is a basis of the vector space R^3:
>> MatR := Dom::Matrix(Dom::Real): S := [MatR([2, 1, 0]), MatR([-3, 1, 1]), MatR([-1, -1, -1])]
-- +- -+ +- -+ +- -+ --
| | 2 | | -3 | | -1 | |
| | | | | | | |
| | 1 |, | 1 |, | -1 | |
| | | | | | | |
| | 0 | | 1 | | -1 | |
-- +- -+ +- -+ +- -+ --
The Gram-Schmidt algorithm then returns an orthogonal basis for R^3. We get an orthonormal basis with the following input:
>> ON := map(linalg::orthog(S), linalg::normalize)
-- +- -+ +- -+ --
| | 1/2 | | 1/2 1/2 | |
| +- -+ | 6 | | 8 15 | |
| | 1/2 | | - ---- | | - ---------- | |
| | 2 5 | | 6 | | 60 | |
| | ------ | | | | | |
| | 5 | | 1/2 | | 1/2 1/2 | |
| | | | 6 | | 8 15 | |
| | 1/2 |, | ---- |, | ---------- | |
| | 5 | | 3 | | 30 | |
| | ---- | | | | | |
| | 5 | | 1/2 | | 1/2 1/2 | |
| | | | 6 | | 8 15 | |
| | 0 | | ---- | | - ---------- | |
| +- -+ | 6 | | 12 | |
-- +- -+ +- -+ --
Example
2The orthogonalization of the vectors:
>> T := {matrix([[-2, 5, 3]]), matrix([[0, 2, 1]])}
{ +- -+ +- -+ }
{ | 0, 2, 1 |, | -2, 5, 3 | }
{ +- -+ +- -+ }
gives:
>> linalg::orthog(T)
{ +- -+ +- -+ }
{ | -2, 5, 3 |, | 13/19, 11/38, -1/38 | }
{ +- -+ +- -+ }
Example
3The result of linalg::orthog is a list or
set of linearly independent vectors, even if the input contains
linearly dependent vectors:
>> MatQ := Dom::Matrix(Dom::Rational): S := [MatQ([2, 1]), MatQ([3, 4]), MatQ([-1, 1])]
-- +- -+ +- -+ +- -+ --
| | 2 | | 3 | | -1 | |
| | |, | |, | | |
| | 1 | | 4 | | 1 | |
-- +- -+ +- -+ +- -+ --
>> linalg::orthog(S)
-- +- -+ +- -+ --
| | 2 | | -1 | |
| | |, | | |
| | 1 | | 2 | |
-- +- -+ +- -+ --
linalg::ogSystemlinalg::onSystem was removed. Use
linalg::orthog and linalg::normalize
instead.