# [Maxima] complex number arithmetic

Stavros Macrakis macrakis at alum.mit.edu
Thu Apr 16 17:51:13 CDT 2009

```On Thu, Apr 16, 2009 at 5:56 PM, Richard Fateman
<fateman at cs.berkeley.edu> wrote:
> You need to choose a principal value for multiple-valued roots.

Agreed, but this is orthogonal: Maxima already has conventions
(whether they are currently correct or not...) in rectform.

> Also try rectform((1+%i)^(1+%i)) for a fun time.

That is why I specified "whenever the result is correctly expressed in
numbers only", the simplest case of which is integral powers.

Barton Willis:
>> With large integer powers, maybe it's not clear what is best.

Well, we already expand large integer powers of rationals.  Why is the
expanded form of (2/3+%i)^100 any worse than (2/3)^100?  It's not even
very slow:
rectform((%i+2/3)^100000) takes only 0.02 secs.

>> Computations such as
>>> a : (2/3 + %i)^(10^9 + 1);
>>> b : (2/3 + %i)^(10^9);
>>> a/b  --> (long number) / (long number) --> 2/3 + %i
>>> are somewhat embarrassing.

Embarrassing in what way?  That Maxima can't take advantage of the
shortcut?  Does it matter?  It is actually surprisingly fast for
reasonable-size exponents.

By the way, I noticed that Maxima, trying to be helpful, writes
rectform((2+%i)^1001) using sin(1001*atan(...)), which messes up