Commits

Aleksey Khudyakov committed f44d6e0

Avoid underflow in invIncompleteGamma

Uderflow occurs in calculation of inital approximation
if a*a = 0 then log(a*a) = -∞ and everything goes awry from this point

Comments (0)

Files changed (1)

Numeric/SpecFunctions.hs

       | t'' <= 1  = exp( (log(a * p) + beta) / p )
       | otherwise = 1 - 2 / (t'' + 1)
       where
-        r   = sqrt ( - log ( a * a ) )
+        r   = sqrt $ - 2 * log a
         y   = r - ( 2.30753 + 0.27061 * r )
                    / ( 1.0 + ( 0.99229 + 0.04481 * r ) * r )
         t   = 1 / (9 * q)