Guest User

Untitled

a guest
May 26th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. -- simple root-finding
  2. f x = x^2 - 100
  3. rootf f a b
  4. | abs(a-b) < epsilon = c
  5. | (f a)*(f c) < 0 = rootf f a c
  6. | (f a)*(f c) > 0 = rootf f c b
  7. | f a == 0 = a
  8. | f b == 0 = b
  9. | f c == 0 = c
  10. where epsilon = 0.00001
  11. c = (a+b)/2
Add Comment
Please, Sign In to add comment