Skip to content

Commit

Permalink
Handle case when guess is NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
Shimuuar committed Mar 20, 2018
1 parent 50de88c commit 51ccc98
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Numeric/RootFinding.hs
Expand Up @@ -370,9 +370,10 @@ newtonRaphsonIterations (lo,guess,hi) function
(flo,_) = function lo
(fhi,_) = function hi
-- Ensure that initial guess is within bracket
guess' | guess < lo && guess < hi = (lo + hi) / 2
| guess > lo && guess > hi = (lo + hi) / 2
| otherwise = guess
guess'
| guess >= lo && guess <= hi = guess
| guess >= hi && guess <= lo = guess
| otherwise = (lo + hi) / 2
--
go xA x xB
| f == 0 = [NewtonRoot x]
Expand Down

0 comments on commit 51ccc98

Please sign in to comment.