Question: import math def f ( x ) : return math.exp ( x ) + 2 * * ( - x ) + 2 * math.cos

import math
def f(x):
return math.exp(x)+2**(-x)+2* math.cos(x)-6
def df(x):
return math.exp(x)-2**(-x)-2* math.sin(x)
def newton_method(initial_guess, tolerance, max_iterations):
print(f"{'n':<5}{'p_n':<10}")
x = initial_guess
for i in range(max_iterations +1):
print(f"{i:<5}{x:.5f}")
if abs(f(x))<= tolerance:
break
x = x - f(x)/ df(x)
# Set the initial guess, tolerance, and maximum iterations
initial_guess =1.5
tolerance =1e-5
max_iterations =5
# Apply Newton's method
newton_method(initial_guess, tolerance, max_iterations)

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!