Created
June 24, 2013 12:42
-
-
Save PhDP/5849775 to your computer and use it in GitHub Desktop.
The bisection algorithm in Haskell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bisection f a b e = if a < b then bis a b else bis b a | |
where err = if e < 1e-15 then 1e-15 else e | |
bis a b = let d = (b - a) / 2; m = (b + a) / 2 in | |
if d < err then | |
m | |
else if f a * f m < 0.0 then | |
bis a m | |
else | |
bis m b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment