Question: def f(x): return x**5 - 4*x**3 - x + 7 #return -(x**5 - 4*x**3 - x + 7) def bisect_first(a, b): ''' Find root of

def f(x):

return x**5 - 4*x**3 - x + 7

#return -(x**5 - 4*x**3 - x + 7)

def bisect_first(a, b):

''' Find root of a continuous function f.

Note one should make sure f(a) * f(b) <= 0

'''

if (f(a) * f(b) > 0):

return " input possibly wrong"

num_steps = 0

c = (a + b) / 2.0

tolerance = 0.01

while ( abs(f(c)) > tolerance ):

if (f(c) < 0):

a = c

else:

b = c

c = (a + b) / 2.0

num_steps = num_steps + 1

print ('# after', num_steps, "guesses we approx. the root of the given polynomial is ", c)

return

bisect_first(-3, -2)

This code prints:

# after 11 guesses we approx. the root of the given polynomial is -2.204345703125

I'm having trouble visualizing python execution. I understand we are using bisection to approximate the root, but I have no idea how the answer was found. Can you please create a table.

Would I start my guess by a number between -3 and -2? Is -3 and -2 plugged into f(x) instead? AS YOU CAN SEE, I'm totally lost.

Thank you, clarify this concept as much as possible. please!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!