# Minimal polynomial of an element in a polynomial quotient ring

Let $$p(z)$$ be a (not necessarily irreducible) polynomial in $$\mathbb{Q}[z]$$. Is there a built-in function I can use for determining the minimal polynomial of an element $$\overline{q(z)} \in \mathbb{Q}[z]/(p(z))$$, i.e. finding the smallest degree nonzero monic polynomial $$Q(z) \in \mathbb{Q}[z]$$ for which $$p(z) ~|~ Q(q(z))$$?

MinimalPolynomial works, but only when $$p(z)$$ is irreducible and thus $$\mathbb{Q}[z] / (p(z))$$ determines a bona fide algebraic number field.

A specific example would help. I'll supply one though I do not know if it is quite what you have in mind.

We will use the extension below.

p = (z^2 - 3)*(z^3 + z^2 + 5*z + 4);

Now suppose we have an element in the extension ring. I picked the one below.

q = z^5 + z^4 - 7*z^2 + 2*z - 4;

The question is how to find a smallest polynomial that is satisfied by q. A way to do this is to set q to a new variable w and take the resultant with p, eliminating x.

Resultant[q - w, p, z]

(* Out[221]= (-107 + 32 w + w^2) (58148 + 4755 w - 75 w^2 + w^3) *)

Now we have a problem: which factor to use? Well, that depends on which factor in p we choose for z. So I guess Out[221] is the best we can do, in the absence of working over an irreducible polynomial extension.