Ask Your Question

Revision history [back]

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

Appreciate your help.