# Strange factoring in e = (x+1)^3*(x+2)^3*(x+3)^3*(x+4)^3

After reading a question about QUORA I had fun with Sage to test expressions factoring. If I ask to factorize e = (x+1)^3(x+2)^3(x+3)^3 everything is ok. But when I ask to factorize e = (x+1)^3(x+2)^3(x+3)^3*(x+4)^3 the result surprises me and I do not understand why! Here is my script and the results.

var('q')
e = (x+1)^3*(x+2)^3*(x+3)^3
print e
print "solve: ", solve(e,x)
#
R = ComplexField(16)['x']       # 16 donne 3 décimales et 32 donne 8 décimales
q = R(e)
print "factor: ", factor(q)
print

e = (x+1)^3*(x+2)^3*(x+3)^3*(x+4)^3
print e
print "solve: ", solve(e,x)
#
R = ComplexField(16)['x']       # 16 donne 3 décimales
q = R(e)
print factor(q)
print
#
R = ComplexField(32)['x']       # 32 donne 8 décimales
q = R(e)
print factor(q)


Now the results

(x + 3)^3*(x + 2)^3*(x + 1)^3
solve:  [
x == -3,
x == -2,
x == -1
]
factor:  (x + 1.000)^3 * (x + 2.000)^3 * (x + 3.000)^3

(x + 4)^3*(x + 3)^3*(x + 2)^3*(x + 1)^3
solve:  [
x == -4,
x == -3,
x == -2,
x == -1
]
(x + 0.8452 - 0.1196*I) * (x + 0.8452 + 0.1196*I) * (x + 1.115 - 0.4330*I) * (x + 1.115 + 0.4330*I) * (x
+ 1.764 - 1.048*I) * (x + 1.764 + 1.048*I) * (x + 2.528) * (x + 2.988 - 1.554*I) * (x + 2.988 + 1.554*I)
* (x + 4.457 - 1.231*I) * (x + 4.457 + 1.231*I) * (x + 5.134)

(x + 1.00000000)^3 * (x + 2.00000000)^3 * (x + 3.00000000)^3 * (x + 4.00000000)^3


As you can see when I the use of ComplexField(16) give me 12 roots (10 complex ans 2 false reals for me).This is totally different of ComplexField(32) which give the right answer. Why? Thank you in advance for enlightening my lantern.

edit retag close merge delete

Sort by » oldest newest most voted

The reason is that Sage's polynomial rings work with expanded polynomials, and the coefficients in the (latter) expanded polynomial are too big to fit in 16 bits:

sage: R.<x> = QQ[]
sage: f = (x+1)^3*(x+2)^3*(x+3)^3*(x+4)^3; f
x^12 + 30*x^11 + 405*x^10 + 3250*x^9 + 17247*x^8 + 63690*x^7 + 167615*x^6 + 316350*x^5 + 424428*x^4 + 94280*x^3 + 240480*x^2 + 86400*x + 13824
sage: f.change_ring(ComplexField(16))
x^12 + 30.00*x^11 + 405.0*x^10 + 3250.*x^9 + 17250.*x^8 + 63690.*x^7 + 167600.*x^6 + 316400.*x^5 + 424400.*x^4 + 394300.*x^3 + 240500.*x^2 + 86400.*x + 13820.


You can also see the problem by adding print q statements to your code.

more

1

Thank you very much for your answer. I think I understand it and do exercises on this subject. Actually print q in my code would have put me on the path. But I also believe that I still have a lot of work to do in the field of SAGE. I have downloaded the free book "Calcul Mathématique avec Sage- Alexandre Casamayou Nathann Cohen ....) and I will study particularly the chapters 11 and 7 that will be very useful, I think, to understand your explanation. Not a problem because I'm retired - I'm 78 years old - and I enjoy solving the little problems that I encounter on the internet (like Euler Project, Turing Challenge, ...) Again thank you for your answer. Excuse me for my Google translation.

( 2018-10-27 03:21:52 -0500 )edit

You're welcome. Indeed those are the relevant chapters in that book. You can accept my answer by clicking the checkmark on the left of it. Good luck with your studies and problem solving.

( 2018-10-27 03:51:52 -0500 )edit