Bisection 82
Bisection 82
import math
def f(x):
return ((x*math.log10(x))-1.2)
if (f(x_0)*f(x_1)<0):
print("Intermediate value theorem is satisfied & hence the initial value will
be",x_0,x_1)
else:
print("The given initial aaproximation is wrong 7 hence not satisfying the
intermediate value theorem")
print("the value of function f(x_0)=",f(x_0))
print("the value of function f(x_1)=",f(x_1))
for i in range(1,n+1,1):
x_2=(x_0 + x_1)/2
print("Iteration_%d, x2= %0.6f & f(x2)= %0.6f \n"%(i,x_2,f(x_2)))
if(f(x_2)<0):
x_0=x_2
else:
x_1=x_2