Ask Your Question
0

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

asked 2023-11-30 08:08:38 +0100

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.

edit retag flag offensive close merge delete

Comments

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?

Max Alekseyev gravatar imageMax Alekseyev ( 2023-11-30 20:51:02 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-12-01 07:31:10 +0100

achrzesz gravatar image

If you need exact results, you can use:

x = PolynomialRing(QQbar, 'x').gen()
f = x^4 + 1
rs = f.roots(ring=QQbar,multiplicities=False)
[f(u).radical_expression() for u in rs]


[0, 0, 0, 0]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-11-30 08:08:38 +0100

Seen: 195 times

Last updated: Dec 01 '23