## `linalg::orthog` -- orthogonalization of vectors

#### Introduction

`linalg::orthog``(S)` orthogonalizes the vectors in S using the Gram-Schmidt orthogonalization algorithm.

#### Call(s)

`linalg::orthog(S)`

#### Parameters

`S` | - | 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`)

#### Returns

a set or a list of vectors, respectively.

#### Related Functions

`linalg::factorQR`, `linalg::isUnitary`, `linalg::normalize`, `linalg::scalarProduct`, `lllint`, `norm`

#### Details

- The vectors in `S` are orthogonalized with respect to the scalar product `linalg::scalarProduct`.
- If O is the returned set, then the vectors of O span the same subspace as the vectors in `S`, and they are pairwise orthogonal, i.e.: v * w = 0 for all v, w in O with v <> w.
- The vectors returned are not normalized. To normalize them use `map(O, linalg::normalize)`.
- For an ordered set of orthogonal vectors, `S` should be a list.
- The vectors in `S` must be defined over the same component ring.
- The component ring of the vectors in `S` must be a field, i.e., a domain of category `Cat::Field`.

#### Example 1

The 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 2

The 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 3

The 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  |  |
                              -- +-   -+  +-    -+ --

#### Changes

- used to be called `linalg::ogSystem`
- The function `linalg::onSystem` was removed. Use `linalg::orthog` and `linalg::normalize` instead.

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000