0% found this document useful (0 votes)
4 views1 page

Bisection 82

The document presents a Python implementation of the Bisection Method for finding roots of a function. It defines a function f(x) and checks if the initial approximations satisfy the Intermediate Value Theorem before iterating to find the root. The final output is the estimated root after a specified number of iterations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Bisection 82

The document presents a Python implementation of the Bisection Method for finding roots of a function. It defines a function f(x) and checks if the initial approximations satisfy the Intermediate Value Theorem before iterating to find the root. The final output is the estimated root after a specified number of iterations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

#Title : Bisection Method

#Name : Sandip Rathod


#Roll no. : S411082

import math
def f(x):
return ((x*math.log10(x))-1.2)

n=int(input("Enter the no. of the equation="))


x_0=int(input("Enter the initial value of x0="))
x_1=int(input("Enter the initial value of x1="))

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

print("\nRequired root is : %0.8f"% x_2)

You might also like