FIX #4228 (atanh (-1) returns NaN instead of -Infinity)
authorghc@cainnorris.net <unknown>
Mon, 16 Aug 2010 21:36:54 +0000 (21:36 +0000)
committerghc@cainnorris.net <unknown>
Mon, 16 Aug 2010 21:36:54 +0000 (21:36 +0000)
Data/Complex.hs
GHC/Float.lhs

index bbc8a07..6965547 100644 (file)
@@ -198,4 +198,4 @@ instance  (RealFloat a) => Floating (Complex a) where
 
     asinh z        =  log (z + sqrt (1+z*z))
     acosh z        =  log (z + (z+1) * sqrt ((z-1)/(z+1)))
-    atanh z        =  log ((1+z) / sqrt (1-z*z))
+    atanh z        =  0.5 * log ((1.0+z) / (1.0-z))
index dbb556f..c31be1b 100644 (file)
@@ -249,7 +249,7 @@ instance  Floating Float  where
 
     asinh x = log (x + sqrt (1.0+x*x))
     acosh x = log (x + (x+1.0) * sqrt ((x-1.0)/(x+1.0)))
-    atanh x = log ((x+1.0) / sqrt (1.0-x*x))
+    atanh x = 0.5 * log ((1.0+x) / (1.0-x))
 
 instance  RealFloat Float  where
     floatRadix _        =  FLT_RADIX        -- from float.h
@@ -331,7 +331,7 @@ instance  Floating Double  where
 
     asinh x = log (x + sqrt (1.0+x*x))
     acosh x = log (x + (x+1.0) * sqrt ((x-1.0)/(x+1.0)))
-    atanh x = log ((x+1.0) / sqrt (1.0-x*x))
+    atanh x = 0.5 * log ((1.0+x) / (1.0-x))
 
 {-# RULES "truncate/Double->Int" truncate = double2Int #-}
 instance  RealFrac Double  where