1

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?

kahcv
  • 636
  • 5
  • 7

2 Answers2

0

Scipy has a fairly extensive set of algorithms for root finding. I am pretty sure they have robust error checking, so you might look there, first.

David
  • 424
  • 3
  • 16
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