Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def bisection(number):
- a = 1.0
- b = number/2.0
- mid = (a+b)/2
- aprox = number -mid*mid
- while math.fabs(aprox) > 0.0001:
- if aprox < 0:
- b = mid
- else:
- a = mid
- mid = (a+b)/2.0
- aprox = number -mid*mid
- return mid
- def heron(number):
- aprox = 1.0
- aprox = (aprox +number)/2.0
- while math.fabs(number -aprox*aprox) >0.0001:
- aprox = (aprox +number/aprox)/2.0
- return aprox
- def newton(number):
- aprox = 1.0
- diff = aprox -number
- while math.fabs(diff) > 0.0001:
- aprox = aprox -(diff)/(2*aprox)
- diff = aprox*aprox -number
- return aprox
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement