# Was not able to correctly evaluate the polynomial with roots of unity

Hello Folks, I am newbie to Sage. I am trying to validate the polynomial using roots of unity over complex field. When evaluating the polynomial using roots of unity, I am expecting polynomial evaluate to zero but instead I am seeing a weird value. But, the same function when computed indvidually seeing expected results. Could you help, if I am doing something wrong here.

I am pasting the sample sage script example for your reference.

sage: x = PolynomialRing(ComplexField(), 'x').gen()
sage: f = x^4 + 1
sage: y = f.roots()
sage: y
[(-0.707106781186548 - 0.707106781186548*I, 1),
(-0.707106781186548 + 0.707106781186548*I, 1),
(0.707106781186548 - 0.707106781186548*I, 1),
(0.707106781186548 + 0.707106781186548*I, 1)]
sage: u = y[0][0]
sage: u
-0.707106781186548 - 0.707106781186548*I
sage: u^4
-1.00000000000000
sage: f(u)
-4.44089209850063e-16


edit retag close merge delete

4.44089209850063e-16 is a very small number (very close to zero), which is expected for non-exact fields like CC. Are you familiar with scientific notation or what is your concern?

( 2023-11-30 20:51:02 +0100 )edit

Sort by ยป oldest newest most voted

If you need exact results, you can use:

x = PolynomialRing(QQbar, 'x').gen()
f = x^4 + 1
rs = f.roots(ring=QQbar,multiplicities=False)

[0, 0, 0, 0]

more