Sponsored links: Algebra eBooks

### The Maxima on-line user's manual

Algebra Calculator

#### Gramschmidt

Function: gramschmidt (<x>)

Function: gramschmidt (<x>, <F>) Carries out the Gram-Schmidt orthogonalization algorithm on <x>, which is either a matrix or a list of lists. <x> is not modified by `gramschmidt`. The inner product employed by `gramschmidt` is <F>, if present, otherwise the inner product is the function `innerproduct`.

If <x> is a matrix, the algorithm is applied to the rows of <x>. If <x> is a list of lists, the algorithm is applied to the sublists, which must have equal numbers of elements. In either case, the return value is a list of lists, the sublists of which are orthogonal and span the same space as <x>. If the dimension of the span of <x> is less than the number of rows or sublists, some sublists of the return value are zero.

`factor` is called at each stage of the algorithm to simplify intermediate results. As a consequence, the return value may contain factored integers.

`load(eigen)` loads this function.

Example:

Gram-Schmidt algorithm using default inner product function.

```          (%i1) load (eigen)\$
(%i2) x: matrix ([1, 2, 3], [9, 18, 30], [12, 48, 60]);
[ 1   2   3  ]
[            ]
(%o2)                    [ 9   18  30 ]
[            ]
[ 12  48  60 ]
(%i3) y: gramschmidt (x);
2      2            4     3
3      3   3 5      2  3  2  3
(%o3)  [[1, 2, 3], [- ---, - --, ---], [- ----, ----, 0]]
2 7    7   2 7       5     5
(%i4) map (innerproduct, [y[1], y[2], y[3]], [y[2], y[3], y[1]]);
(%o4)                       [0, 0, 0]```

Gram-Schmidt algorithm using a specified inner product function.

```          (%i1) load (eigen)\$
(%i2) ip (f, g) := integrate (f * g, u, a, b);
(%o2)          ip(f, g) := integrate(f g, u, a, b)
(%i3) y : gramschmidt ([1, sin(u), cos(u)], ip), a= -%pi/2, b=%pi/2;
%pi cos(u) - 2
(%o3)              [1, sin(u), --------------]
%pi
(%i4) map (ip, [y[1], y[2], y[3]], [y[2], y[3], y[1]]), a= -%pi/2, b=%pi/2;
(%o4)                       [0, 0, 0]```

```(%o1)                                true
(%i2) ```

### Related Examples

##### gramschmidt-matrix

M:matrix([-1,1,0],[1,...

gramschmidt(M);

Calculate

##### gramschmidt-load-matrix

load (eigen);

x: matrix ([1, i, 1]...

y: gramschmidt (x);

Calculate

##### gramschmidt-load-matrix

load(eigen);

x: matrix ([16, 5,9, ...

y: gramschmidt(x);

Calculate

##### gramschmidt-load-matrix

load (eigen);

v1: vector(1, 2);

v2: vector(1, -2);

Calculate

v1:[1,-1,1];

v2:[-2,3,-1];

v3:[1,2,-4];

Calculate

##### gramschmidt-load-matrix

load (eigen);

x: matrix ([2, 1, 0]...

y: gramschmidt (x);

Calculate

##### gramschmidt-load-map-matrix

load (eigen);

x: matrix ([3,3,1,1]...

y: gramschmidt (x);

Calculate

v1:[1,-1,1];

v2:[-2,3,-1];

v3:[1,2,-4];

Calculate

##### gramschmidt-integrate-load-map

load (eigen);

ip (f, g) := integra...

y : gramschmidt ([-3...

Calculate

##### gramschmidt-matrix

x: matrix ([-1, 0, 0,...

y: gramschmidt (x);

Calculate