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

Bisection Method - Docx 77

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)
7 views1 page

Bisection Method - Docx 77

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

#Name:Jyotsna Mulik

#Roll No._S411077
#Title:Bisection Method

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

#Input data
n=int(input("enter the number of iteration n="))
x_0=int(input("enter the initial value x0="))
x_1=int(input("enter the initial value x1="))
if ((f(x_0)*f(x_1))<0):
print("intermidate value theorem is satisfied and hence the initial value will
be",x_0,x_1)
else:
print("the given initial approximation is wrong and hence not satisfying
intermidate 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 and 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("\n required root is : %0.8f" %x_2)

You might also like