# Fixed iteration method to find approximate root
from math import sqrt
#function definition
def f(x):
f1=1.0/sqrt(1+x)
return f1
e=0.0001
x0=float(input("Enter starting value "))
while abs(f(x0)-x0)>=e:
x0=f(x0)
print 'The best approximation to root is %.4f'%(x0)
No comments:
Post a Comment