1 2 3 4 5 6 7 8 9 10 11 12 13
ctr=0 def computeRoot(poly, x_0, epsilon): ctr=0 y=42 while not(abs(y)<=abs(epsilon)): ctr=ctr+1 y=0 dy=0 for thing in range(len(poly)): y+=poly[thing]*(x_0**thing) dy+=(thing-1)*poly[thing]*(x_0**(thing-1)) x_0=x_0-(y/dy) return [x_0,ctr]