I have a polynomial with integer coefficients. The coefficients are very large(~200-300 digits). I need to find integer roots of this polynomial. I used numpy.roots() to find the roots, but the roots are not accurate. Sage does find the roots accurately. I am aware that there are algorithms to find integer roots of polynomials with integer coefficients. Is there implementation of such an algorithm in any python library which I can use directly? OR How can I find integer roots of polynomial with integer coefficients in python?
Asked
Active
Viewed 375 times
2 Answers
0
I am not a professional but i tried this. (let me know if it works)
def roots(a,b,c):
'''
root Formula.
'''
r1=(-b+(b**2-4*a*c)**(1/2))/(2*a)
r2=(b+(b**2-4*a*c)**(1/2))/(2*a)
return r1,r2
call
result=roots(1,1,300)
print(result)
#gives result in form of tuple
thank you.

ketan gangal
- 33
- 1
- 8
-
Sry. I should have mentioned it earlier. My polynomial is a degree-9 polynomial. So this will not work. – kahcv May 16 '20 at 03:45
-