Merge pull request #233 from ashu01/master

typo fix
This commit is contained in:
Harshil 2017-12-30 15:05:16 +05:30 committed by GitHub
commit a033150426
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,13 +9,13 @@ def bisection(function, a, b): # finds where the function becomes 0 in [a,b] us
return a return a
elif function(b) == 0: elif function(b) == 0:
return b return b
elif function(a) * function(b) > 0: # if noone of these are root and they are both possitive or negative, elif function(a) * function(b) > 0: # if none of these are root and they are both positive or negative,
# then his algorith can't find the root # then his algorithm can't find the root
print("couldn't find root in [a,b]") print("couldn't find root in [a,b]")
return return
else: else:
mid = (start + end) / 2 mid = (start + end) / 2
while abs(start - mid) > 0.0000001: # untill we achive percise equals to 10^-7 while abs(start - mid) > 0.0000001: # until we achieve precise equals to 10^-7
if function(mid) == 0: if function(mid) == 0:
return mid return mid
elif function(mid) * function(start) < 0: elif function(mid) * function(start) < 0: