There is a function minpoly
to compute the minimal polynomial of an algebraic expression:
In [71]: rt = S(1)/3 + (-S(7)/2 - 21*sqrt(3)*I/2)**(S(1)/3)/3 + (-S(7)/2 + 21*sqrt(3)*I/2)**(S(1)/3)/3
In [72]: rt
Out[72]:
_______________ _______________
╱ 7 21⋅√3⋅ⅈ ╱ 7 21⋅√3⋅ⅈ
3 ╱ - ─ - ─────── 3 ╱ - ─ + ───────
1 ╲╱ 2 2 ╲╱ 2 2
─ + ─────────────────── + ───────────────────
3 3 3
In [73]: minpoly(rt)
Out[73]:
3 2
x - x - 2⋅x + 1
That shows that this is a root of the polynomial that you showed. In general of r
is a root of a polynomial p
then minpoly(r)
is a polynomial that divides p
.
We can also use minpoly
to prove that the expression after substituting the root into the polynomial is zero:
In [74]: p = x**3-x**2-2*x+1
In [75]: p.subs(x, rt)
Out[75]:
2 3
_______________ ⎛ _______________ _______________⎞ ⎛ _______________ _______________⎞
╱ 7 21⋅√3⋅ⅈ ⎜ ╱ 7 21⋅√3⋅ⅈ ╱ 7 21⋅√3⋅ⅈ ⎟ ⎜ ╱ 7 21⋅√3⋅ⅈ ╱ 7 21⋅√3⋅ⅈ ⎟
2⋅3 ╱ - ─ + ─────── ⎜ 3 ╱ - ─ - ─────── 3 ╱ - ─ + ─────── ⎟ ⎜ 3 ╱ - ─ - ─────── 3 ╱ - ─ + ─────── ⎟
1 ╲╱ 2 2 ⎜1 ╲╱ 2 2 ╲╱ 2 2 ⎟ ⎜1 ╲╱ 2 2 ╲╱ 2 2 ⎟
─ - ───────────────────── - ⎜─ + ─────────────────── + ───────────────────⎟ + ⎜─ + ─────────────────── + ───────────────────⎟
3 3 ⎝3 3 3 ⎠ ⎝3 3 3 ⎠
_______________
╱ 7 21⋅√3⋅ⅈ
2⋅3 ╱ - ─ - ───────
╲╱ 2 2
- ─────────────────────
3
In [76]: minpoly(p.subs(x, rt))
Out[76]: x
Here the minimal polynomial is x
whose only root is zero.
https://en.wikipedia.org/wiki/Minimal_polynomial_(field_theory)
https://docs.sympy.org/latest/modules/polys/reference.html#sympy.polys.numberfields.minpoly