Closed selinger closed 10 years ago
The implementation of asin(x) is not correct for x <= -0.5. The range should be between -pi/2 and pi/2. To reproduce:
Prelude Data.Number.CReal> asin (-0.4) :: CReal -0.4115168460674880193847378976173356048557 Prelude Data.Number.CReal> asin (-0.5) :: CReal -2.6179938779914943653855361527329190701643 Prelude Data.Number.CReal> asin (-0.6) :: CReal -2.4980915447965088516598341545545211284225
Note in particular the discontinuity at x=-0.5. Compare:
Prelude Data.Number.CReal> asin (-0.4) :: Double -0.41151684606748806 Prelude Data.Number.CReal> asin (-0.5) :: Double -0.5235987755982989 Prelude Data.Number.CReal> asin (-0.6) :: Double -0.6435011087932844
To fix: replace the line
{- x0 < 0 -} atan (s/x) - pi / 2
by
{- x0 < 0 -} - atan (s/x) - pi / 2
Note: this also affects acos(x), but only because it is defined in terms of asin(x). Changing the above line will fix both functions.
The implementation of asin(x) is not correct for x <= -0.5. The range should be between -pi/2 and pi/2. To reproduce:
Prelude Data.Number.CReal> asin (-0.4) :: CReal -0.4115168460674880193847378976173356048557 Prelude Data.Number.CReal> asin (-0.5) :: CReal -2.6179938779914943653855361527329190701643 Prelude Data.Number.CReal> asin (-0.6) :: CReal -2.4980915447965088516598341545545211284225
Note in particular the discontinuity at x=-0.5. Compare:
Prelude Data.Number.CReal> asin (-0.4) :: Double -0.41151684606748806 Prelude Data.Number.CReal> asin (-0.5) :: Double -0.5235987755982989 Prelude Data.Number.CReal> asin (-0.6) :: Double -0.6435011087932844
To fix: replace the line
by
Note: this also affects acos(x), but only because it is defined in terms of asin(x). Changing the above line will fix both functions.