Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- simple root-finding
- f x = x^2 - 100
- rootf f a b
- | abs(a-b) < epsilon = c
- | (f a)*(f c) < 0 = rootf f a c
- | (f a)*(f c) > 0 = rootf f c b
- | f a == 0 = a
- | f b == 0 = b
- | f c == 0 = c
- where epsilon = 0.00001
- c = (a+b)/2
Add Comment
Please, Sign In to add comment