Ask your own question, for FREE!
Computer Science 8 Online
OpenStudy (anonymous):

Python: Newston-Raphson I am getting too many iterations and my answer is off in the millions decimal place. Any ideas?

OpenStudy (anonymous):

How many is too many? What level of accuracy do you actually want?

OpenStudy (anonymous):

i posted that q by mistake the actual question is how do i use newtons method fr findin roots of a polynomial ?

OpenStudy (anonymous):

First u need a guess and the guess must be reasonably close to the actual root.

OpenStudy (anonymous):

So let your polynomial be some function of x, f(x) and your initial guess be x_0. Then x_1 = x_0 - f(x_0) / f ' (x_0) and iterate till u reach a desired accuracy.

OpenStudy (anonymous):

tried this

OpenStudy (anonymous):

def computeRoot(poly,x_0,epsilon): count=0 while abs(evaluatePoly(poly,x_0))>epsilon: x1=x_0-(evaluatePoly(poly,x_0)/computeDeriv(poly,x_0)) x_0=x1 count=count+1 return [x1,count]

OpenStudy (anonymous):

print computeRoot([-13.39, 0.0, 17.5, 3.0, 1.0], 0.1, .0001)

OpenStudy (anonymous):

heres the error Traceback (most recent call last): File "<pyshell#64>", line 1, in <module> print computeRoot([-13.39, 0.0, 17.5, 3.0, 1.0], 0.1, .0001) File "<pyshell#63>", line 5, in computeRoot x1=x_0-(evaluatePoly(poly,x_0)/computeDeriv(poly,x_0)) ZeroDivisionError: float division by zero

OpenStudy (anonymous):

Well, if computeDeriv(poly,x_0) (ie the value of the derivative) is zero, you will get this error, no?

OpenStudy (anonymous):

What is the polynomial and what is your initial guess?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!