+{-# LANGUAGE CPP, DeriveDataTypeable #-}
+
-----------------------------------------------------------------------------
-- |
-- Module : Data.Complex
import Data.Typeable
#ifdef __GLASGOW_HASKELL__
-import Data.Generics.Basics( Data )
+import Data.Data (Data)
#endif
#ifdef __HUGS__
{-# SPECIALISE magnitude :: Complex Double -> Double #-}
magnitude :: (RealFloat a) => Complex a -> a
magnitude (x:+y) = scaleFloat k
- (sqrt ((scaleFloat mk x)^(2::Int) + (scaleFloat mk y)^(2::Int)))
+ (sqrt (sqr (scaleFloat mk x) + sqr (scaleFloat mk y)))
where k = max (exponent x) (exponent y)
mk = - k
+ sqr z = z * z
-- | The phase of a complex number, in the range @(-'pi', 'pi']@.
-- If the magnitude is zero, then so is the phase.
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))