\section{Generic Complex Arithmetics}
This module introduces complex arithmetics to Rascal. Complex numbers can be
created by using the "complex"-function and it is often handy to define the
purely imaginary constant $i$. As soon $i$ has been defined, Rascal uses $i$
for output. Politically correct you may also use $j$ as the imaginary unit.

\begin{lyxcode}
>complex(1,2)+3

~complex(4,2)

>i=complex(0,1);

>(5+3*i)*(2+i)

~(7+4*i)

>
\end{lyxcode}

The real and imaginary part of a complex number can be accessed like the
cells of vectors: The first cell is the real, the second the imaginary
value. Additionally like matrices complex values can consist of all
different types of data. The "transpose" of a complex value is the complex
conjugate.

\begin{lyxcode}
>f(x)=x*x(1)+x(2);

>f(complex("x",4))

~complex("x*x+4","4*(x)")

>(2+3*complex(0,1))' 

~complex(2,-3)  
\end{lyxcode}

The following standard functions are defined for complex: {\tt exp, log,
pow, sqrt, sin, cos, tan, cot, asin, acos, atan, acot, sinh, cosh, tanh,
coth, asinh, acoth, atanh, acoth}. The function {\tt arg} computes the
argument, the function {\tt abs} the absolute value. The standard functions
{\tt sqrt, pow} for integers and doubles are being overridden by the
corresponding complex versions.

The {\tt log} represents the main value of the natural logarithm, the {\tt
pow(a,b)} or {\tt a\^{}b} is evaluated as $a^b=e^{b\ln a}$, the {\tt sqrt(a)} 
as $a^\frac12$ and the rest is determined based on these functions and the
pendants on the real axis.

One could also define a complex out of matrices, but this is not advisable
as this easily gets confusing and Rascal prefers complex values within
matrices. You should also be aware that naively plugging interval-datatypes
into a generic complex datatype will not yield verified results: As an
example the {\tt arg} function has to be treated differently, and most other
standard functions depend on this.
