# Revision history [back]

You could do something like the following.

$sage -v SageMath version 8.1, Release Date: 2017-12-07$ sage -q
sage: P.<x> = QQ[]
sage: f = P([QQ.random_element() for _ in range(6)])
sage: f
x^4 - 2*x^3 - x^2 + x + 8
sage: f.roots()
[]
sage: f_roots = f.roots(QQbar, multiplicities=False)
sage: f_roots
[-0.9308781364905225? - 0.9859665944129413?*I,
-0.9308781364905225? + 0.9859665944129413?*I,
1.930878136490523? - 0.7891098514623471?*I,
1.930878136490523? + 0.7891098514623471?*I]
sage: alpha = f_roots[0]
sage: K = QQ[alpha]
sage: K
Number Field in a with defining polynomial x^4 - 2*x^3 - x^2 + x + 8
sage: K['x'](f).factor()
(x - a) * (x^3 + (a - 2)*x^2 + (a^2 - 2*a - 1)*x + a^3 - 2*a^2 - a + 1)