I am getting too many iterations and my answer is off in the millions decimal place. Any ideas?
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
def evaluate_poly(poly, x):
#evaluates a polynomial input as a tuple for a specific x value
for i in poly:
#returns a tuple representing the derivative
#of the input polynomial as a tuple
for i in poly:
def compute_root(poly, x, epsilon):
#find the root of the polynomial poly using
#evaluates the current x value of the derivative of the polynomial
while abs(value) > epsilon:
return x, iterations
#outputs a the root and number of iterations as a tuple
I get an output of (0.80679329312..., 139)
the answer is supposed to be (0.806790679..., 8)
My answer for the root is darn close, but why so am I getting so many iterations?
I tried debugging it but all the numbers seem normal on every iteration, I'm just not getting there fast enough somehow...
my answer is within epsilon of the given answer, so I'm really just worried about the iterations
A million decimal places.....? or the millionths place? :P
Not the answer you are looking for? Search for more explanations.
The millionth place, actually I had the wrong value for epsilon, it should have been 0.0001
with that correction I get (0.8067887806273476, 141) and the given answer is (0.80679075379635201, 8)
Since my answer and the given answer differ by a number less than epsilon=0.0001 the answer is not what I'm worried about, it's the fact that my algorithm uses 141 iterations when it's only supposed to use 8 !
I'm going to do this painfully on paper and see if I can debug this to find which variable(s) is/are misbehaving.
is # a comment?
and never mind, problem solved!
if the problem is solved could u pls giv me the soln??