sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.43k stars 478 forks source link

Can not find the numerical roots of a certain 10th degree integer polynomial #38437

Open mathlusiverse opened 3 months ago

mathlusiverse commented 3 months ago

Steps To Reproduce

The following will cause exception in Sagemath:

solve( 2048*x^10 + 4096*x^9 + 4096*x^8 + 2560*x^7 + 1280*x^6 + 544*x^5 + 192*x^4 + 48*x^3 + 12*x^2 + 2*x + 1 == 0, x, to_poly_solve=True)

But if I change the coefficient of x^10 from 2048 to 2047 or 2049, Sagemath can solve it.

solve( 2047*x^10 + 4096*x^9 + 4096*x^8 + 2560*x^7 + 1280*x^6 + 544*x^5 + 192*x^4 + 48*x^3 + 12*x^2 + 2*x + 1 == 0, x, to_poly_solve=True)

The original equation can be solved using the public account of Mathematica Alpha, which gives the following approximate solutions (they are conjugate pairs, only five are shown here):

x ≈ -0.546401 + 0.272543 i
x ≈ -0.526856 - 0.447181 i
x ≈ -0.197604 + 0.378467 i
x ≈  0.111461 + 0.429596 i
x ≈  0.159401 + 0.225766 i

Expected Behavior

Expect to see 5 pairs of conjugate complex numbers.

Actual Behavior

It throws the following exception:

TypeError: 'sage.symbolic.expression.Expression' object is not subscriptable

Additional Information

I changed many coefficients slightly, Sagemath can solve them. Sagemath can handle similar 10th degree polynomial equations. The roots of the original and slightly modified 10th degree equations have similar (visual) behavior, they spread out quite nicely on the complex plane.

Environment

- **OS**: Mac Sonoma 14.5
- **Sage Version**: SageMath version 10.2, Release Date: 2023-12-03

Checklist

fchapoton commented 3 months ago

It seems that maxima returns a factorisation instead of all solutions:

sage: ex=2048*x^10 + 4096*x^9 + 4096*x^8 + 2560*x^7 + 1280*x^6 + 544*x^5 + 192*x^4 + 48*x^3 + 12*x^2 + 2*x + 1 == 0
sage: solve(ex,x)
[0 == 128*x^5 + 128*x^4 + 64*x^3 + 16*x^2 + 8*x + I*sqrt(7) + 1, 0 == 128*x^5 + 128*x^4 + 64*x^3 + 16*x^2 + 8*x - I*sqrt(7) + 1]

and then our conversion fails on that maxima output.