# [Maxima] expanding complex formulas

Barton Willis willisb at unk.edu
Sat Dec 5 17:16:11 CST 2009

```The imaginary unit in Maxima is %i. I think you want expand((a + %i *
b)^2).

declare(b,complex) tells the Maxima simplifier to assume that the
variable 'b' might be complex valued. The simplifier uses such
declarations to decide how to simplify; example:

(%i11) declare(b,complex)\$

(%i12) abs(b^2);
(%o12) abs(b)^2

With no declare(a,complex), we have

(%i13) abs(a^2);
(%o13) a^2

Barton

-----maxima-bounces at math.utexas.edu wrote: -----

>To: maxima at math.utexas.edu
>From: Folkert van Heusden <folkert at vanheusden.com>
>Sent by: maxima-bounces at math.utexas.edu
>Date: 12/05/2009 03:48PM
>Subject: [Maxima] expanding complex formulas
>
>Hi,
>
>Am trying to expand formulas with complex values.
>E.g.:
>
>(%i1) declare(b,complex);
>(%o1)                                done
>(%i2) (a+b)^2;
>                                          2
>(%o2)                              (b + a)
>(%i3) expand(%i2);
>                                 2            2
>(%o3)                           b  + 2 a b + a
>(%i4) realpart(expand(%i2));
>                      2                                2       2
>(%o4)         realpart (b) + 2 a realpart(b) - imagpart (b) + a
>(%i5)
>
>But this seems to be wrong.
>
>As far as I know (a+b.i)^2 would be something like:
>re: a^2-y^2
>im: 2.a.b.i
>
>What am I doing wrong?
>
>
>Folkert van Heusden
>
>--
>----------------------------------------------------------------------
>Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
>_______________________________________________
>Maxima mailing list
>Maxima at math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima

```