Commit 6458b8dc authored by alekzcb's avatar alekzcb Committed by Ben Gamari

base: Update acosh to handle -1::Complex

Summary: Fixes #8532

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #8532

Differential Revision: https://phabricator.haskell.org/D3916
parent cd857dd4
......@@ -197,7 +197,8 @@ instance (RealFloat a) => Floating (Complex a) where
where (x':+y') = log (((1-y):+x) / sqrt (1+z*z))
asinh z = log (z + sqrt (1+z*z))
acosh z = log (z + (z+1) * sqrt ((z-1)/(z+1)))
-- Take care to allow (-1)::Complex, fixing #8532
acosh z = log (z + (sqrt $ z+1) * (sqrt $ z-1))
atanh z = 0.5 * log ((1.0+z) / (1.0-z))
log1p x@(a :+ b)
......
......@@ -34,6 +34,7 @@ test('numrun012', normal, compile_and_run, [''])
test('numrun013', normal, compile_and_run, [''])
test('numrun014', normal, compile_and_run, [''])
test('numrun015', normal, compile_and_run, [''])
test('numrun016', normal, compile_and_run, [''])
test('arith016', normal, compile_and_run, [''])
test('arith017', normal, compile_and_run, [''])
test('arith018', normal, compile_and_run, [''])
......
-- test for trac #8532
import Data.Complex
main :: IO ()
main = do
print $ acosh ((-1)::Complex Double)
print $ acosh ((-1)::Complex Float)
0.0 :+ 3.141592653589793
0.0 :+ 3.1415927
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment