Accelerating the pace of engineering and science

# Documentation Center

• Trials
• Product Updates

# linalg::orthog

Orthogonalization of vectors

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```linalg::orthog(S, <Real>)
```

## Description

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

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.: for all with .

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.

If you use the Real option, linalg::orthog computes an orthogonal basis using a real scalar product in the orthogonalization process.

## Examples

### Example 1

The following list of vectors is a basis of the vector space 3:

```MatR := Dom::Matrix(Dom::Real):
S := [MatR([2, 1, 0]), MatR([-3, 1, 1]), MatR([-1, -1, -1])]```

The Gram-Schmidt algorithm then returns an orthogonal basis for 3. We get an orthonormal basis with the following input:

`ON:= linalg::orthog(S)`

The vectors can be normalized using linalg::normalize:

`map(ON, linalg::normalize)`

We may also build a matrix from the vectors in S an apply linalg::orthog to this matrix. The result is the matrix whose columns are given by the above elements of the list ON:

`A:= S[1].S[2].S[3]`

`linalg::orthog(A)`

### Example 2

The orthogonalization of the vectors:

`T := {matrix([[-2, 5, 3]]), matrix([[0, 2, 1]])}`

gives:

`linalg::orthog(T)`

### 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])]```

`linalg::orthog(S)`

### Example 4

Compute an orthogonal basis of this matrix:

```A := matrix([[a, 1], [1, a]]):
linalg::orthog(A)```

To avoid complex conjugates, use the Real option:

`linalg::orthog(A, Real)`

## Parameters

 S A set or list of vectors of the same dimension (a vector is an n ⨉ 1 or 1 ⨉ n matrix of a domain of category Cat::Matrix) or a matrix

## Options

 Real Avoid using a complex scalar product in the orthogonalization process.

## Return Values

Set or a list of vectors, respectively.

## See Also

### MuPAD Functions

Was this topic helpful?