# Revision history [back]

### Minimal polynomial isn't minimal?

Quoting MathWorld,

The minimal polynomial of a matrix $A$ is the monic polynomial in $A$ of smallest degree $n$ such that

$$p(A) = \sum_{i=0}^n c_i A^i = 0$$.

I'd like to find the minimal polynomial of a matrix $A$ over the reals. My attempt:

sage: A = matrix(RR, [
....:     [0,-9, 0, 0, 0, 0],
....:     [1, 6, 0, 0, 0, 0],
....:     [0, 0, 0,-9, 0, 0],
....:     [0, 0, 1, 6, 0, 0],
....:     [0, 0, 0, 0, 0,-5],
....:     [0, 0, 0, 0, 1, 0]
....: ])
sage: f = A.minpoly()
sage: f.is_monic()
True
sage: f(A).is_zero()
True


However, $f$ doesn't appear to actually be the minimal polynomial:

sage: R.<x> = RR['x']
sage: g = x^4 - 6*x^3 + 14*x^2 - 30*x + 45
sage: g(x).is_monic()
True
sage: g(A).is_zero()
True
sage: g.degree() < f.degree()
True


Did I make a mistake or is this a bug?

### Minimal polynomial isn't minimal?

Quoting MathWorld,

The minimal polynomial of a matrix $A$ is the monic polynomial in $A$ of smallest degree $n$ such that

$$p(A) = \sum_{i=0}^n c_i A^i = 0$$.

I'd like to find the minimal polynomial of a matrix $A$ over the reals. My attempt:

sage: A = matrix(RR, [
....:     [0,-9, 0, 0, 0, 0],
....:     [1, 6, 0, 0, 0, 0],
....:     [0, 0, 0,-9, 0, 0],
....:     [0, 0, 1, 6, 0, 0],
....:     [0, 0, 0, 0, 0,-5],
....:     [0, 0, 0, 0, 1, 0]
....: ])
sage: f = A.minpoly()
sage: f.is_monic()
True
sage: f(A).is_zero()
True


However, $f$ doesn't appear to actually be the minimal polynomial:

sage: R.<x> = RR['x']
sage: g = x^4 - 6*x^3 + 14*x^2 - 30*x + 45
sage: g(x).is_monic()
True
sage: g(A).is_zero()
True
sage: g.degree() < f.degree()
True


Did I make a mistake or is this a bug?

I noticed that A.minpoly() gives $g$ if I do the computation over $\mathbb{Q}$ instead of $\mathbb{R}$. Perhaps the minpoly function just needs to be restricted to exact rings?

 3 retagged tmonteil 23843 ●26 ●172 ●438 http://wiki.sagemath.o...

### Minimal polynomial isn't minimal?

Quoting MathWorld,

The minimal polynomial of a matrix $A$ is the monic polynomial in $A$ of smallest degree $n$ such that

$$p(A) = \sum_{i=0}^n c_i A^i = 0$$.

I'd like to find the minimal polynomial of a matrix $A$ over the reals. My attempt:

sage: A = matrix(RR, [
....:     [0,-9, 0, 0, 0, 0],
....:     [1, 6, 0, 0, 0, 0],
....:     [0, 0, 0,-9, 0, 0],
....:     [0, 0, 1, 6, 0, 0],
....:     [0, 0, 0, 0, 0,-5],
....:     [0, 0, 0, 0, 1, 0]
....: ])
sage: f = A.minpoly()
sage: f.is_monic()
True
sage: f(A).is_zero()
True


However, $f$ doesn't appear to actually be the minimal polynomial:

sage: R.<x> = RR['x']
sage: g = x^4 - 6*x^3 + 14*x^2 - 30*x + 45
sage: g(x).is_monic()
True
sage: g(A).is_zero()
True
sage: g.degree() < f.degree()
True


Did I make a mistake or is this a bug?

I noticed that A.minpoly() gives $g$ if I do the computation over $\mathbb{Q}$ instead of $\mathbb{R}$. Perhaps the minpoly function just needs to be restricted to exact rings?