next up previous index
Next: Algebra Up: Numbers Previous: Sums and Products

Complex Numbers

The imaginary  unit  is denoted by %I in Maxima, and by I in Maple and Mathematica. All three know how to handle complex numbers, although in Maxima you may have to force things a little:

Maxima: 

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}(C7) (3 + 5 * %I) / (7 + ...
...I 41
(D8) ----- + --
65 65
(C9)\end{verbatim}\end{tex2html_preform}\end{figure}

Maple:

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}> (3 + 5 * I) / (7 + 4 * I);
41 23
-- + -- I
65 65>\end{verbatim}\end{tex2html_preform}\end{figure}

Mathematica:

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}In[6]:= (3 + 5 I) / (7 + ...
...ut[6]= -- + ----
65 65In[7]:=\end{verbatim}\end{tex2html_preform}\end{figure}

In Maxima you can convert a complex number given in rectangular format  to angular format as follows:

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}(C9) polarform(%);
%I AT...
...10) 0.72324057067957914 %E
(C11)\end{verbatim}\end{tex2html_preform}\end{figure}

Now the same in Maple:

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}> convert(%, polar);
1/2...
...
.6307692305 + .3538461537 I>\end{verbatim}\end{tex2html_preform}\end{figure}

And now it is Mathematica's term:

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}In[7]:= Abs[%] Exp[I Arg[...
...
Out[7]= Sqrt[--] E
65In[8]:=\end{verbatim}\end{tex2html_preform}\end{figure}

Here we had to assemble the number by hand. There is no precooked Polarform function. We can do it by hand in Maxima and Maple too. Here's Maxima:
\begin{figure}
\begin{tex2html_preform}\begin{verbatim}(C11) rectform((3 + 5 * %...
...----------------
SQRT(65)
(C13)\end{verbatim}\end{tex2html_preform}\end{figure}

$\ldots$ and now the same in Maple:
\begin{figure}
\begin{tex2html_preform}\begin{verbatim}> (3 + 5 * I) / (7 + 4 * ...
... 1/65 2210 exp(I arctan(--))
41\end{verbatim}\end{tex2html_preform}\end{figure}

Whatever the form of the number, we can always extract its imaginary  and real part. This is how we would do it in Maxima:

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}(C31) realpart(%) + %I * ...
... 23 %I + 41
(D32) ----------
65\end{verbatim}\end{tex2html_preform}\end{figure}

Function radcan simplifies an arithmetic expression by converting it into a canonical form.

Now the same in Maple:

\begin{figure}
\begin{tex2html_preform}\begin{verbatim}> Re(%) + I * Im(%);
41 23
-- + -- I
65 65>\end{verbatim}\end{tex2html_preform}\end{figure}

$\ldots$ and in Mathematica:
\begin{figure}
\begin{tex2html_preform}\begin{verbatim}In[8]:= Re[%] + I Im[%]...
...ut[8]= -- + ----
65 65In[9]:=\end{verbatim}\end{tex2html_preform}\end{figure}

All three programs are clever enough to know that $e^{i\pi} = -1$. Here's Maxima:

(C33) carg(-1);
(D33)                                 %PI
(C34)
Here's Maple:
> argument(-1);
                                      Pi

>
But Mathematica has just a little problem with it:
In[10]:= Arg[-1];

In[11]:= Arg[-1 + 0 I]

Out[11]= Pi

In[12]:=
Its function Arg works on complex numbers only.


next up previous index
Next: Algebra Up: Numbers Previous: Sums and Products
Zdzislaw Meglicki
2001-02-26