enternetusers > References > Haskell reference
| Indexes | Syntax | Prelude | Ratio | >> Complex << | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random

Complex

Complex numbers are an algebraic type. The constructor (:+) forms a complex number from its real and imaginary rectangular components. This constructor is strict: if either the real part or the imaginary part of the number is _|_, the entire number is _|_. A complex number may also be formed from polar components of magnitude and phase by the function mkPolar. The function cis produces a complex number from an angle t. Put another way, cis t is a complex value with magnitude 1 and phase t (modulo 2p).

The function polar takes a complex number and returns a (magnitude, phase) pair in canonical form: The magnitude is nonnegative, and the phase, in the range (- p, p]; if the magnitude is zero, then so is the phase.

The functions realPart and imagPart extract the rectangular components of a complex number and the functions magnitude and phase extract the polar components of a complex number. The function conjugate computes the conjugate of a complex number in the usual way.

The magnitude and sign of a complex number are defined as follows:

abs z   =  magnitude z :+ 0
signum 0   =  0
signum z@(x:+y)   =  x/r :+ y/r  where r = magnitude z

That is, abs z is a number with the magnitude of z, but oriented in the positive real direction, whereas signum z has the phase of z, but unit magnitude.


module Complex(Complex((:+)), realPart, imagPart, conjugate, mkPolar,
               cis, polar, magnitude, phase)  where

infix  6  :+

data  (RealFloat a)     => Complex a = !a :+ !a  deriving (Eq,Read,Show)


realPart, imagPart :: (RealFloat a) => Complex a -> a
realPart (x:+y)  =  x
imagPart (x:+y)  =  y

conjugate  :: (RealFloat a) => Complex a -> Complex a
conjugate (x:+y) =  x :+ (-y)

mkPolar  :: (RealFloat a) => a -> a -> Complex a
mkPolar r theta  =  r * cos theta :+ r * sin theta

cis  :: (RealFloat a) => a -> Complex a
cis theta  =  cos theta :+ sin theta

polar  :: (RealFloat a) => Complex a -> (a,a)
polar z  =  (magnitude z, phase z)

magnitude :: (RealFloat a) => Complex a -> a
magnitude (x:+y) =  scaleFloat k
     (sqrt ((scaleFloat mk x)^2 + (scaleFloat mk y)^2))
    where k  = max (exponent x) (exponent y)
          mk = - k

phase :: (RealFloat a) => Complex a -> a
phase (0 :+ 0) = 0
phase (x :+ y) = atan2 y x


instance  (RealFloat a) => Num (Complex a)  where
    (x:+y) + (x':+y') =  (x+x') :+ (y+y')
    (x:+y) - (x':+y') =  (x-x') :+ (y-y')
    (x:+y) * (x':+y') =  (x*x'-y*y') :+ (x*y'+y*x')
    negate (x:+y) =  negate x :+ negate y
    abs z =  magnitude z :+ 0
    signum 0 =  0
    signum z@(x:+y) =  x/r :+ y/r  where r = magnitude z
    fromInteger n =  fromInteger n :+ 0

instance  (RealFloat a) => Fractional (Complex a)  where
    (x:+y) / (x':+y') =  (x*x''+y*y'') / d :+ (y*x''-x*y'') / d
   where x'' = scaleFloat k x'
 y'' = scaleFloat k y'
 k   = - max (exponent x') (exponent y')
 d   = x'*x'' + y'*y''

    fromRational a =  fromRational a :+ 0

instance  (RealFloat a) => Floating (Complex a) where
    pi             =  pi :+ 0
    exp (x:+y)     =  expx * cos y :+ expx * sin y
                      where expx = exp x
    log z          =  log (magnitude z) :+ phase z

    sqrt 0         =  0
    sqrt z@(x:+y)  =  u :+ (if y < 0 then -v else v)
                      where (u,v) = if x < 0 then (v',u') else (u',v')
                            v'    = abs y / (u'*2)
                            u'    = sqrt ((magnitude z + abs x) / 2)

    sin (x:+y)     =  sin x * cosh y :+ cos x * sinh y
    cos (x:+y)     =  cos x * cosh y :+ (- sin x * sinh y)
    tan (x:+y)     =  (sinx*coshy:+cosx*sinhy)/(cosx*coshy:+(-sinx*sinhy))
                      where sinx  = sin x
                            cosx  = cos x
                            sinhy = sinh y
                            coshy = cosh y

    sinh (x:+y)    =  cos y * sinh x :+ sin  y * cosh x
    cosh (x:+y)    =  cos y * cosh x :+ sin y * sinh x
    tanh (x:+y)    =  (cosy*sinhx:+siny*coshx)/(cosy*coshx:+siny*sinhx)
                      where siny  = sin y
                            cosy  = cos y
                            sinhx = sinh x
                            coshx = cosh x

    asin z@(x:+y)  =  y':+(-x')
                      where  (x':+y') = log (((-y):+x) + sqrt (1 - z*z))
    acos z@(x:+y)  =  y'':+(-x'')
                      where (x'':+y'') = log (z + ((-y'):+x'))
                            (x':+y')   = sqrt (1 - z*z)
    atan z@(x:+y)  =  y':+(-x')
                      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)))
    atanh z        =  log ((1+z) / sqrt (1-z*z))


Partner sites:

Board Shorts >>


Quiksilver Board Shorts
Roxy Board Shorts
Volcom Board Shorts
Billabong Board Shorts
Quicksilver Board Shorts
Hurley Board Shorts
Quicksilveredition Board Shorts
Rusty Board Shorts
Reef Board Shorts
oneill Board Shorts

Ezekiel surf clothing Board Shorts
Paul Frank surf clothing Board Shorts
Mada surf clothing Board Shorts
Analog surf clothing Board Shorts
Quicksilver surf clothing Board Shorts
Jet Pilot surf clothing Board Shorts
Quicksilveredition surf clothing Board Shorts
Dakine surf clothing Board Shorts
Matix surf clothing Board Shorts
Reef surf clothing Board Shorts
O'neil surf clothing Board Shorts

Also, you will want to check out Stanton California so you can see what's up and they are part of Stanton City Hall as well.

You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here: quiksilver tees http://www.killerdana.com/killerdana/search2.asp?SearchResults.SearchHandle=QT1NZW5zIFNTIFRlZXN_Qj1NZW5zIFNTIFRlZXN_RD01OX5FPTBeMV4yXm51bV9uZXd_ST1QcmljZX5LPTR_TD0xfk09NH5OPTN_&SearchResults.SortAscending=False&SearchResults.SortBy=num_new&Answer=766

quiksilver shirt Quiksilver Shirt

quiksilver board short quiksilver board short

quiksilver clothing Quiksilver clothing

quiksilver apparel Quiksilver apparel

quiksilver jackets quiksilver jacket

quiksilver jeans Quiksilver Shirt

Quiksilver Shirt

Quiksilver Pants

quiksilver shoes Quiksilver Shoes

quiksilver sweaters Quiksilver Sweaters

quiksilver tank Quiksilver Tanks

quiksilver tees Quiksilver Tops

Quiksilver Tees

quiksilver wetsuits Quiksilver Wetsuits

Quiksilver Wetsuits

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter

This is the guy we need in government office. His name is Kevin Carr City Of Stanton Council Candidate and he is a great guy. and we can get surf t shirts surfing shirt and Swim Shop for swim wear wimming gear women's and men's This is the guy we need in government office. His name is Kevin Carr City Of Stanton Council Candidate and he is a great guy. and we can get surf t shirts surfing shirt and Swim Shop for swim wear wimming gear women's and men's

 

French Lavender Soaps Organic And Natural Body Care Shea Body Butters

If you may be in the market for French Lavender Soaps or Thyme Body Care,
or even Shea Body Butters, ShopErba has the finest products available

Ken Arnold is the Democratic Candidate For the 68th Assembly District.

Board Shorts >>


Quiksilver Board Shorts
Roxy Board Shorts
Volcom Board Shorts
Billabong Board Shorts
Quicksilver Board Shorts
Hurley Board Shorts
Quicksilveredition Board Shorts
Rusty Board Shorts
Reef Board Shorts
oneill Board Shorts

Ezekiel surf clothing Board Shorts
Paul Frank surf clothing Board Shorts
Mada surf clothing Board Shorts
Analog surf clothing Board Shorts
Quicksilver surf clothing Board Shorts
Jet Pilot surf clothing Board Shorts
Quicksilveredition surf clothing Board Shorts
Dakine surf clothing Board Shorts
Matix surf clothing Board Shorts
Reef surf clothing Board Shorts
O'neil surf clothing Board Shorts

Also, you will want to check out Stanton California so you can see what's up and they are part of Stanton City Hall as well.

You can also get Organic Skin Care products from Bliss Bath Body and you must check out their Natural Body Lotions and bath soaps

Now if you are looking for the best deals on surf clothing from Quiksilver and Roxy then you have to check these amazing deals here: quiksilver tees http://www.killerdana.com/killerdana/search2.asp?SearchResults.SearchHandle=QT1NZW5zIFNTIFRlZXN_Qj1NZW5zIFNTIFRlZXN_RD01OX5FPTBeMV4yXm51bV9uZXd_ST1QcmljZX5LPTR_TD0xfk09NH5OPTN_&SearchResults.SortAscending=False&SearchResults.SortBy=num_new&Answer=766

quiksilver shirt Quiksilver Shirt

quiksilver board short quiksilver board short

quiksilver clothing Quiksilver clothing

quiksilver apparel Quiksilver apparel

quiksilver jackets quiksilver jacket

quiksilver jeans Quiksilver Shirt

Quiksilver Shirt

Quiksilver Pants

quiksilver shoes Quiksilver Shoes

quiksilver sweaters Quiksilver Sweaters

quiksilver tank Quiksilver Tanks

quiksilver tees Quiksilver Tops

Quiksilver Tees

quiksilver wetsuits Quiksilver Wetsuits

Quiksilver Wetsuits

Hey, check out this Organic Skin Care European Soaps along with Natural Lavender Body Lotion and shea butter