HELP COMPLEX                                   R. J. Duncan, August 1990

Complex numbers.


    CONTENTS - (Use <ENTER> g to access required sections)

 -- The Complex Module
 -- The Complex Type
 -- Basic Arithmetic
 -- Mathematical Functions
 -- Trigonometric Functions


-- The Complex Module -------------------------------------------------

signature Complex
structure Complex : Complex
    The structure -Complex- is  an autoloadable library module  defining
    the type  of  complex numbers.  It  is described  by  the  following
    signature:

        signature Complex = sig

            (* The Complex Type *)

            eqtype complex

            val complex     : real * real -> complex
            val uncomplex   : complex -> real * real

            val imagpart    : complex -> real
            val realpart    : complex -> real

            (* Useful Constants *)

            val zero        : complex
            val one         : complex
            val i           : complex
            val pi          : complex

            (* Basic Arithmetic *)

            val ~           : complex -> complex
            val +           : complex * complex -> complex
            val -           : complex * complex -> complex
            val *           : complex * complex -> complex
            val /           : complex * complex -> complex

            val abs         : complex -> complex
            val sign        : complex -> complex

            val conjugate   : complex -> complex

            (* Basic Functions *)

            exception Ln
            exception Log10
            exception Power

            val sqrt        : complex -> complex
            val exp         : complex -> complex
            val ln          : complex -> complex
            val log10       : complex -> complex
            val power       : complex -> complex -> complex

            val **          : complex * complex -> complex

            (* Trigonometric Functions *)

            val phase       : complex -> complex

            val sin         : complex -> complex
            val cos         : complex -> complex
            val tan         : complex -> complex

            val arcsin      : complex -> complex
            val arccos      : complex -> complex
            val arctan      : complex -> complex

            val arcsinh     : complex -> complex
            val arccosh     : complex -> complex
            val arctanh     : complex -> complex

            val sinh        : complex -> complex
            val cosh        : complex -> complex
            val tanh        : complex -> complex

        end


-- The Complex Type ---------------------------------------------------

eqtype complex
    The type of  complex numbers.  A complex number  is a  pair of  real
    numbers: the real and imaginary parts. Two complex numbers are equal
    if their real and imaginary parts are equal.


val complex (r : real, i : real) : complex
val uncomplex (n : complex) : real * real
    The function -complex- constructs the complex number with real  part
    -r- and  imaginary  part  -i-;  -uncomplex-  returns  the  real  and
    imaginary parts of the complex  number -n-. These two functions  are
    inverses.


val realpart (n : complex) : real
val imagpart (n : complex) : real
    Return the real and imaginary parts of the complex number -n-.


val zero : complex
val one  : complex
val i    : complex
val pi   : complex
    Useful constants, defined:

        val zero = complex(0.0, 0.0)
        val one  = complex(1.0, 0.0)
        val i    = complex(0.0, 1.0)
        val pi   = complex(Real.pi, 0.0)


-- Basic Arithmetic ---------------------------------------------------

val ~ (n : complex) : complex
val (n1 : complex)  +  (n2 : complex) : complex
val (n1 : complex)  -  (n2 : complex) : complex
val (n1 : complex)  *  (n2 : complex) : complex
val (n1 : complex)  /  (n2 : complex) : complex
    Standard  arithmetic  operations  on  complex  numbers.  Raise   the
    exception -Overflow- on overflow or division by zero.


val abs (n : complex) : complex
    Returns the absolute value of the complex number -n-. Definition:

        fun abs n =
            let val (r, i) = uncomplex n
            in  complex(sqrt(r * r + i * i), 0.0)
            end;

    Raises the  exception  -Overflow- if  any  intermediate  computation
    overflows.


val sign (n : complex) : complex
    Returns the sign -s- of the complex number -n-, such that

        abs(s) = 1.0, phase(s) = phase(n)


val conjugate (n : complex) : complex
    Returns the complex conjugate of -n-. Definition:

        fun conjugate n =
            let val (r, i) = uncomplex n
            in  complex(r, ~i)
            end;


-- Mathematical Functions ---------------------------------------------

val sqrt (n : complex) : complex
    Returns the principal square root of the complex number -n-.


exception Ln
val ln (n : complex) : complex
    Returns the natural logarithm of the complex number -n-. Raises  the
    exception -Ln- if -n- is zero.


exception Log10
val log10 (n : complex) : complex
    Returns the base 10 logarithm of the complex number -n-. Raises  the
    exception -Log10- if -n- is zero.


val exp (n : complex) : complex
    Returns e raised to the  power -n-. Raises the exception  -Overflow-
    if the result is out of range.


exception Power
infix 8 **
val (n : complex) ** (m : complex) : complex
val power (n : complex) (m : complex) : complex
    Returns the  value  of -n-  raised  to  the power  -m-.  Raises  the
    exception -Power-  if  -n-  is  zero and  -m-  is  non-positive,  or
    -Overflow- if the result is out of range.


-- Trigonometric Functions --------------------------------------------

NB: all angles are measured in radians.


val phase (n : complex) : complex
    Returns the complex phase angle of -n-. Definition:

        fun phase n =
            let val (r, i) = uncomplex n
            in  complex(Real.arctan2 r i, 0.0)
            end;


val sin (n : complex) : complex
val cos (n : complex) : complex
val tan (n : complex) : complex
    Return the sine, cosine and tangent of the complex angle -n-.


val arcsin (n : complex) : complex
val arccos (n : complex) : complex
val arctan (n : complex) : complex
    Return the arcsine, arccosine and  arctangent of the complex  number
    -n-. The function -arctan- raises the exception -Overflow- if -n- is
    i or ~i.


val sinh (n : complex) : complex
val cosh (n : complex) : complex
val tanh (n : complex) : complex
    Return the hyperbolic sine, hyperbolic cosine and hyperbolic tangent
    of the complex angle -n-.


val arcsinh (n : complex) : complex
val arccosh (n : complex) : complex
val arctanh (n : complex) : complex
    Return the hyperbolic arcsine,  hyperbolic arccosine and  hyperbolic
    arctangent of the complex number -n-. The function -arctanh-  raises
    the exception -Overflow- if -n- is 1.0 or ~1.0.


--- C.all/pml/help/complex
--- Copyright University of Sussex 1991. All rights reserved. ----------
