Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

explain the need for human resource strategies in organisations

Answered: 1 week ago

Question

describe the stages involved in human resource planning

Answered: 1 week ago