geodavic / poly_factor

A function library in C for polynomial factorization.
1 stars 0 forks source link

Verbose output says root is integer when the real part is zero #10

Open geodavic opened 2 years ago

zhangfq-chemistry commented 2 years ago

I use your code to dispose Huckel molecular method(https://daniloroccatano.blog/2018/05/23/the-simple-huckel-method/). To expand the huckel determiant and factor the polynomial and solve. I found that only your code provides correct answer in github.

geodavic commented 2 years ago

Glad to hear this will be useful for you. Have you used the web version of the code? It is here: https://web.ma.utexas.edu/users/gdavtor/poly_factor.html

That has the degree limited to 20. If you need a bigger degree, I can increase it. If you get an "Internal Server Error" likely you should pass a larger Precision parameter (128 or 256 will usually do the job).

Alternatively, if you want to execute the code yourself, please let me know which Windows compiler you are using and I will try to provide a build command that is compatible.

zhangfq-chemistry commented 2 years ago

Please increase the degree to 300 if possible, because I will use it to dispose fullenenes (C60,C70, and C240). The integer is very large, and maybe you can use 256. I have no problem to compile your code under ubuntu 21, but I do not know how to build it under windows.

geodavic commented 2 years ago

This factorization method becomes extremely inefficient for high degree polynomials, unless the polynomial has many many low degree factors. So degree 300 is probably out of reach for this code. What is the polynomial? Do you expect it to have many factors?

zhangfq-chemistry commented 2 years ago

Sure, it is difficult to expand large huckel matrix based on symbol computation. The following one is from carbon 60. x^60-90x^58+3825x^56-24x^55-102160x^54+1920x^53+1925160x^52-72240x^51-27244512x^50+1700640x^49+300906380x^48-28113600x^47-2661033600x^46+347208896x^45+19180834020x^44-3327625680x^43-114118295000x^42+25376437920x^41+565407465144x^40-156652575440x^39-2346799508400x^38+792175427520x^37+8189116955350x^36-3308173115904x^35-24056403184260x^34+11466942645600x^33+59443188508110x^32-33076275953760x^31-123163094844616x^30+79417625268960x^29+212712221820840x^28-158412719276240x^27-303315997028160x^26+261359090670624x^25+351861389316780x^24-354145195147200x^23-324375523213200x^22+390055074762240x^21+228227031040884x^20-344185906596720x^19-112654402736360x^18+238553091055200x^17+29617003666920x^16-126428882536240x^15+4679380503120x^14+49433493646080x^13-8131429397135x^12-13627897407360x^11+3576552321006x^10+2527365617120x^9-831616531095x^8-310065067080x^7+108565938200x^6+26034025632x^5-7440712560x^4-1566501120x^3+186416640x^2+54743040x+2985984 (x+2)^4(x-1)^9(x-3)(x^2+x+3)^3(x^2-4x+1)^4(x^2-x+1)^5(x^2-3x-1)^5*(x^4-3x^3-2x^2+7x+1)^3 = 0

geodavic commented 2 years ago

I increased the maximum degree to 300. You can try out your polynomials.

Note: due to Google Cloud limitations, I had to put a limit on computation time. So if any primitive factors have degree greater than 20, the process will stop. In your example above, there are no primitive factors of degree greater than 20 (the biggest is 4), so it should work.

zhangfq-chemistry commented 2 years ago

Would you like to replace the ”gmp.h,mpc.h and mpfr.h“ with big-int library (https://github.com/faheel/BigInt)? So I can compile it under windows. Thanks!

geodavic commented 2 years ago

That would require an entire rewrite. Have you tried using the code within a docker container? There is a docker file included.

Install docker on your machine and then from the root directory of the repo, do docker build poly_factor .

Once that finishes, do docker run --name poly_factor poly_factor to start the container and then in another window docker exec -it poly_factor bash. Then you'll be in the container (which is basically a Linux machine) and can execute the code (it will already be compiled)