Ask Your Question

Revision history [back]

Do you want exact results or approximations? For exact results, you can define

R.<x> = PolynomialRing(QQ)
f = R(x^2*((x+1/x)^2-1))
K.<a> = f.splitting_field()

so you can do:

sage: f.change_ring(K).factor()
(x - a) * (x + a - 1) * (x - a + 1) * (x + a)
sage: f.change_ring(K).roots()
[(a, 1), (-a + 1, 1), (a - 1, 1), (-a, 1)]
sage: beta = f.leading_coefficient()
sage: beta*prod(r[0]^r[1] for r in f.change_ring(K).roots())
1

By Vieta's formulas what you get is just $(-1)^n f_0$ where $n$ is the degree of $f$ and $f_0$ is its constant coefficient.

If you are wondering what $a$ is in the above: it is a root of

sage: a.minpoly()
x^2 - x + 1

As for numerics, you can do e.g.:

sage: f.change_ring(QQbar).roots()
[(-0.500000000000000? - 0.866025403784439?*I, 1),
(-0.500000000000000? + 0.866025403784439?*I, 1),
 (0.500000000000000? - 0.866025403784439?*I, 1),
 (0.500000000000000? + 0.866025403784439?*I, 1)]
sage: beta*prod(r[0]^r[1] for r in f.change_ring(QQbar).roots())
1.000000000000000? + 0.?e-18*I

Do you want exact results or approximations? For exact results, you can define

R.<x> = PolynomialRing(QQ)
f = R(x^2*((x+1/x)^2-1))
K.<a> = f.splitting_field()

so you can do:

sage: f.change_ring(K).factor()
(x - a) * (x + a - 1) * (x - a + 1) * (x + a)
sage: f.change_ring(K).roots()
[(a, 1), (-a + 1, 1), (a - 1, 1), (-a, 1)]
sage: beta = f.leading_coefficient()
sage: beta*prod(r[0]^r[1] for r in f.change_ring(K).roots())
1

By Vieta's formulas what you get is just $(-1)^n f_0$ where $n$ is the degree of $f$ and $f_0$ is its constant coefficient.

sage: beta*prod(r[0]^r[1] for r in f.change_ring(K).roots()) == (-1)^f.degree()*f.constant_coefficient()
True

If you are wondering what $a$ is in the discussion above: it is a root of

sage: a.minpoly()
x^2 - x + 1

As for numerics, you can do e.g.:

sage: f.change_ring(QQbar).roots()
[(-0.500000000000000? - 0.866025403784439?*I, 1),
(-0.500000000000000? + 0.866025403784439?*I, 1),
 (0.500000000000000? - 0.866025403784439?*I, 1),
 (0.500000000000000? + 0.866025403784439?*I, 1)]
sage: beta*prod(r[0]^r[1] for r in f.change_ring(QQbar).roots())
1.000000000000000? + 0.?e-18*I

Do you want exact results or approximations? For exact results, you can define

R.<x> = PolynomialRing(QQ)
f = R(x^2*((x+1/x)^2-1))
K.<a> = f.splitting_field()

so you can do:

sage: f.change_ring(K).factor()
(x - a) * (x + a - 1) * (x - a + 1) * (x + a)
sage: f.change_ring(K).roots()
[(a, 1), (-a + 1, 1), (a - 1, 1), (-a, 1)]
sage: beta = f.leading_coefficient()
sage: myprod = beta*prod(r[0]^r[1] for r in f.change_ring(K).roots())
f.change_ring(K).roots()); myprod
1

By Vieta's formulas what you get is just $(-1)^n f_0$ where $n$ is the degree of $f$ and $f_0$ is its constant coefficient.

sage: beta*prod(r[0]^r[1] for r in f.change_ring(K).roots()) myprod == (-1)^f.degree()*f.constant_coefficient()
True

If you are wondering what $a$ is in the discussion above: it is a root of

sage: a.minpoly()
x^2 - x + 1

As for numerics, you can do e.g.:

sage: f.change_ring(QQbar).roots()
[(-0.500000000000000? - 0.866025403784439?*I, 1),
(-0.500000000000000? + 0.866025403784439?*I, 1),
 (0.500000000000000? - 0.866025403784439?*I, 1),
 (0.500000000000000? + 0.866025403784439?*I, 1)]
sage: beta*prod(r[0]^r[1] for r in f.change_ring(QQbar).roots())
1.000000000000000? + 0.?e-18*I

Do you want exact results or approximations? For exact results, you can define

R.<x> = PolynomialRing(QQ)
f = R(x^2*((x+1/x)^2-1))
K.<a> = f.splitting_field()

so you can do:

sage: f.change_ring(K).factor()
(x - a) * (x + a - 1) * (x - a + 1) * (x + a)
sage: f.change_ring(K).roots()
[(a, 1), (-a + 1, 1), (a - 1, 1), (-a, 1)]
sage: beta = f.leading_coefficient()
sage: myprod = beta*prod(r[0]^r[1] for r in f.change_ring(K).roots()); myprod
1

By Vieta's formulas what you get is just $(-1)^n f_0$ where $n$ is the degree of $f$ $n = \deg(f)$ and $f_0$ is its the constant coefficient.coefficient of $f$.

sage: myprod == (-1)^f.degree()*f.constant_coefficient()
True

If you are wondering what $a$ is in the discussion above: it is a root of

sage: a.minpoly()
x^2 - x + 1

As for numerics, you can do e.g.:

sage: f.change_ring(QQbar).roots()
[(-0.500000000000000? - 0.866025403784439?*I, 1),
(-0.500000000000000? + 0.866025403784439?*I, 1),
 (0.500000000000000? - 0.866025403784439?*I, 1),
 (0.500000000000000? + 0.866025403784439?*I, 1)]
sage: beta*prod(r[0]^r[1] for r in f.change_ring(QQbar).roots())
1.000000000000000? + 0.?e-18*I