Accelerating the pace of engineering and science

# minpoly

Minimal polynomial of matrix

minpoly(A)
minpoly(A,var)

## Description

minpoly(A) returns a vector of the coefficients of the minimal polynomial of A. If A is a symbolic matrix, minpoly returns a symbolic vector. Otherwise, it returns a vector with elements of type double.

minpoly(A,var) returns the minimal polynomial of A in terms of var.

## Input Arguments

 A Matrix. var Free symbolic variable. Default: If you do not specify var, minpoly returns a vector of coefficients of the minimal polynomial instead of returning the polynomial itself.

## Examples

Compute the minimal polynomial of the matrix A in terms of the variable x:

```syms x
A = sym([1 1 0; 0 1 0; 0 0 1]);
minpoly(A, x)```
```ans =
x^2 - 2*x + 1```

To find the coefficients of the minimal polynomial of A, call minpoly with one argument:

```A = sym([1 1 0; 0 1 0; 0 0 1]);
minpoly(A)```
```ans =
[ 1, -2, 1]```

Find the coefficients of the minimal polynomial of the symbolic matrix A. For this matrix, minpoly returns the symbolic vector of coefficients:

```A = sym([0 2 0; 0 0 2; 2 0 0]);
P = minpoly(A)```
```P =
[ 1, 0, 0, -8]```

Now find the coefficients of the minimal polynomial of the matrix B, all elements of which are double-precision values. Note that in this case minpoly returns coefficients as double-precision values:

```B = [0 2 0; 0 0 2; 2 0 0];
P = minpoly(B)```
```P =
1     0     0    -8```