# Revision history [back]

This is what you are looking for:

sage: P.<x> = QQ[]
sage: f = x^3+2*x+5 # f = P([5,2,0,1]) if you want
sage: f_roots = f.roots(QQbar, multiplicities=False)
sage: f_roots
[-1.328268855668609?,
0.664134427834305? - 1.822971095411114?*I,
0.664134427834305? + 1.822971095411114?*I]
sage: alpha = f_roots[0]
sage: K = QQ[alpha]
sage: K['x'](f).is_irreducible()
False
sage: factors = K['x'](f).factor()
sage: factors
(x - a) * (x^2 + a*x + a^2 + 2)
sage: g = factors[1][0]
sage: g
x^2 + a*x + a^2 + 2
sage: L.<b> = K.extension(g)
sage: L
Number Field in b with defining polynomial x^2 + a*x + a^2 + 2 over its base field
sage: L['x'](g).factor()
(x - b) * (x + b + a)
sage: L['x'](f).factor()
(x - b) * (x - a) * (x + b + a)


This is what you are looking for:works for this particular case:

sage: P.<x> = QQ[]
sage: f = x^3+2*x+5 # f = P([5,2,0,1]) if you want
sage: f_roots = f.roots(QQbar, multiplicities=False)
sage: f_roots
[-1.328268855668609?,
0.664134427834305? - 1.822971095411114?*I,
0.664134427834305? + 1.822971095411114?*I]
sage: alpha = f_roots[0]
sage: K = QQ[alpha]
sage: K['x'](f).is_irreducible()
False
sage: factors = K['x'](f).factor()
sage: factors
(x - a) * (x^2 + a*x + a^2 + 2)
sage: g = factors[1][0]
sage: g
x^2 + a*x + a^2 + 2
sage: L.<b> = K.extension(g)
sage: L
Number Field in b with defining polynomial x^2 + a*x + a^2 + 2 over its base field
sage: L['x'](g).factor()
(x - b) * (x + b + a)
sage: L['x'](f).factor()
(x - b) * (x - a) * (x + b + a)


This works for this particular case:

case:
sage: P.<x> = QQ[]
sage: f = x^3+2*x+5 x^3+2x+5 # f = P([5,2,0,1]) if you want
sage: f_roots = f.roots(QQbar, multiplicities=False)
sage: f_roots
[-1.328268855668609?,
0.664134427834305? - 1.822971095411114?*I,
1.822971095411114?I,
0.664134427834305? + 1.822971095411114?*I]
1.822971095411114?I]
sage: alpha = f_roots[0]
sage: K = QQ[alpha]
sage: K['x'](f).is_irreducible()
sage: K'x'.is_irreducible()
False
sage: factors = K['x'](f).factor()
K'x'.factor()
sage: factors
(x - a) * (x^2 + a*x ax + a^2 + 2)
sage: g = factors[1][0]
sage: g
x^2 + a*x ax + a^2 + 2
sage: L.<b>     sage: L. = K.extension(g)
sage: L
Number Field in b with defining polynomial x^2 + a*x ax + a^2 + 2 over its base field
sage: L['x'](g).factor()
sage: L'x'.factor()
(x - b) * (x + b + a)
sage: L['x'](f).factor()
sage: L'x'.factor()
(x - b) * (x - a) * (x + b + a)

a)

This works for this particular case: case:

sage: P.<x> = QQ[]
sage: f = x^3+2x+5 x^3+2*x+5 # f = P([5,2,0,1]) if you want
sage: f_roots = f.roots(QQbar, multiplicities=False)
sage: f_roots
[-1.328268855668609?,
0.664134427834305? - 1.822971095411114?I,
1.822971095411114?*I,
0.664134427834305? + 1.822971095411114?I]
1.822971095411114?*I]
sage: alpha = f_roots[0]
sage: K = QQ[alpha]
sage: K'x'.is_irreducible()
K['x'](f).is_irreducible()
False
sage: factors = K'x'.factor()
K['x'](f).factor()
sage: factors
(x - a) * (x^2 + ax a*x + a^2 + 2)
sage: g = factors[1][0]
sage: g
x^2 + ax a*x + a^2 + 2
sage: L. L.<b> = K.extension(g)
sage: L
Number Field in b with defining polynomial x^2 + ax a*x + a^2 + 2 over its base field
sage: L'x'.factor()
L['x'](g).factor()
(x - b) * (x + b + a)
sage: L'x'.factor()
L['x'](f).factor()
(x - b) * (x - a) * (x + b + a)a)