Write a computer program in Python for \"EXAMPLE 5.5\" on page 136 EXAMPLE 5.5 F
ID: 3908448 • Letter: W
Question
Write a computer program in Python for "EXAMPLE 5.5" on page 136
EXAMPLE 5.5 False Position Problem Statement. Use the false-position method to determine the root of the same equation investigated in Example 5.1 [Eq (E5.1.)]. Solution. As in Example 5.3, initiate the computation with guesses of x,-12 and 16 First iteration: xi = 12 x" = 16 x,= 16- f(x) = 6.1139 f(x")=-2.2303 2.2303(12- 16) 6.1139 (2.2303) = 14.309 which has a true relative error of 0.88 percent. Second iteration: f(x)f(x) -1.5376Explanation / Answer
'''
A bisection method in python starting with interval [a,b] with tolrrance accuracy acc
f(x) = x^2 - 7
'''
def f(x):
return math.pow(x,2) - 7
def biection_method(a,b,tol):
if f(a)*f(b) > 0:
print("No root found")
else:
while (b-a)/2.0 > acc:
nextx = b - (f(b)*(a-b))/f(a)-f(b)
if f(nextx) == 0:
return nextx
elif f(a)*f(nextx) < 0:
b = nextx
else:
a = nextx
return(nextx)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.