Question: def f ( x ) : return - 1 2 - 2 1 * x + 1 5 . 2 5 * x * *

def f(x):
return -12-21*x +15.25*x**2
def false_position(xl, xu, tol=1e-5):
if f(xl)* f(xu)>=0:
print("False Position method fails.")
return None
max_iterations =100
for iteration in range(max_iterations):
# Calculate the point using the false position formula
x_root = xu -(f(xu)*(xl - xu))/(f(xl)- f(xu))
if f(x_root)==0.0:
return x_root
# Update the bounds based on the function value at the root
if f(x_root)* f(xl)<0:
xu = x_root
else:
xl = x_root
# Calculate relative error
relative_error = abs((xu - xl)/ x_root)*100
if relative_error < tol *100:
return x_root
return x_root
# Initial guesses
xl =-5 # You may need to adjust this
xu =0
# Calculate the root
root = false_position(xl, xu)
print(f"The first root of the given function is: {root:.6f}")

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!