Question: ( a ) the bisection method ( b ) Ridders' method ( c ) Steffensen's method ( d ) the Newton - Raphson method The

(a) the bisection method
(b) Ridders' method
(c) Steffensen's method
(d) the Newton-Raphson method
The events:
(a) Find x that satisfies f(x)=tanh(x-3)-0.3+x2=0
(b) Find x that satisfies f(x)=0.7sin(3x)+x-2=0
(c) Find x that satisfies f(x)=(1+erfx)(1+x2)-50=0
For each equation, I guarantee that there is only one root in the interval 0x10. For bisection
and Ridders, you should start the bracketing at x=0 and x=10. For Steffensen and Newton-
Raphson, you should start with a first guess at the midpoint x=5.
In each event, each contestant's score is the number of function evaluations (of either f or f') that
it takes before reaching the root with an absolute tolerance |f(x)|10-10.
Your mission: code up the methods yourselves (i.e., don't use canned root-finding routines),
determine all 12 scores, and crown the
evaluations =0
x = x_start
while True:
f_x = f(x)
evaluations +=1
if abs(f_x) tol:
break
x_next = x -(f_x**2)/(f(x+f_x)- f_x)
evaluations +=1
if abs(x_next - x) tol:
break
x = x_next
return x, evaluations
def newton_raphson_method(f, df, x_start, tol=1e-
:
evaluations =0
x = x_start
while True:
f_x = f(x)
df_x = df(x)
evaluations +=2
if abs(f_x) tol:
break
x_next = x - f_x / df_x
if abs(x_next - x) tol:
break
x = x_next
return evaluations
#function definitions
def func1(x):
return math.tanh(x -3)-0.3+ x /2
def func2(x):
return 0.7* math.sin(3*x)+ x -2
def func3(x):
return (1+ erf(x))*(1+x**2)-50winner (with the lowest total score).
ERROR
TypeError
Traceback (most recent call last)
Cell In[152], line 102
100 for i,f in enumerate(function
s):
101 if method_name == "Newton-
Raphson":
-->102 root, evals = method(
f[0], f[1], start[0])
103 else:
104 root, evals = method(
f, start[0], start[1] if len(start)>1
else start[0])
TypeError: cannot unpack non-iterable i
nt object
TypeError
Traceback (most recent call last)
Cell In[154], line 102
100 for i, f in enumerate(function
s):
101 if method_name == "Steffe
nsen":
-->102 root, evals = method(
f[0], f[1], start[0])
103 else:
104 root, evals = method(
f, start[0], start[1] if len(start)>
1 else start[0])
TypeError: 'function' object is not su
bscriptable WHY AM I GETTING THESE ERRORS DEBUG
( a ) the bisection method ( b ) Ridders' method

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 Programming Questions!