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

Algebra Calculator

#### Charpoly

Function: charpoly (<M>, <x>) Returns the characteristic polynomial for the matrix <M> with respect to variable <x>. That is, `determinant (<M> - diagmatrix (length (<M>), <x>))`.

```          (%i1) a: matrix ([3, 1], [2, 4]);
[ 3  1 ]
(%o1)                       [      ]
[ 2  4 ]
(%i2) expand (charpoly (a, lambda));
2
(%o2)                lambda  - 7 lambda + 10
(%i3) (programmode: true, solve (%));
(%o3)               [lambda = 5, lambda = 2]
(%i4) matrix ([x1], [x2]);
[ x1 ]
(%o4)                        [    ]
[ x2 ]
(%i5) ev (a . % - lambda*%, %th(2)[1]);
[ x2 - 2 x1 ]
(%o5)                     [           ]
[ 2 x1 - x2 ]
(%i6) %[1, 1] = 0;
(%o6)                     x2 - 2 x1 = 0
(%i7) x2^2 + x1^2 = 1;
2     2
(%o7)                     x2  + x1  = 1
(%i8) solve ([%th(2), %], [x1, x2]);
1               2
(%o8) [[x1 = - -------, x2 = - -------],
sqrt(5)         sqrt(5)```

1 2 [x1 = -------, x2 = -------]] sqrt(5) sqrt(5)

There are also some inexact matches for `charpoly`. Try `?? charpoly` to see them.

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

### Related Examples

##### charpoly-debugmode-matrix-true

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

charpoly(M,x);

debugmode(true);

Calculate

##### charpoly-determinant-matrix

J:matrix([0, 1, 0, 0]...

A:-L*matrix([1,0,0,0]...

determinant(J);

Calculate

##### charpoly-coeff-eliminate-expand-matrix-plot2d-sublis

m: matrix([-3*s1-2*s2...

cp: expand(charpoly(m...

eq1: coeff(cp, x, 0);

Calculate

##### charpoly-coeff-expand-matrix-solve

m: matrix([-3*s1-2*s2...

cpc: expand(charpoly(...

eq1: coeff(cp, x, 0);

Calculate

##### charpoly-matrix

m: matrix([4,-1,-1],[...

charpoly(m,x);

Calculate

##### charpoly-matrix

a: matrix ([0.75,0.05...

charpoly(a,x);

Calculate

A:matrix([-A1-c,-A3,-...

determinant(A);

Calculate

##### charpoly-ev-expand-invert-matrix-transpose

m:matrix([3,2,0,0],[0...

a:matrix([0,0,1,0],[0...

b:invert(a);

Calculate

##### charpoly-echelon-eigenvalues-eigenvectors-factor-matrix

A:matrix([1,-1,1],[7,...

eigenvalues(A);

eigenvectors(A);

Calculate

##### charpoly-coeff-determinant-diagmatrix-matrix-ratexpand-solve-transpose

A:matrix([2,1+t,0],[1...

expr:charpoly(A,x);

expr2:ratexpand(expr);

Calculate