# [Maxima] complex expressions

Stavros Macrakis macrakis at alum.mit.edu
Wed Jun 6 12:20:35 CDT 2012

```If I understand your issue correctly, it has nothing to do with
realpart/imagpart "not working" -- it has to do with Maxima's noun/verb
scheme.

Expand doesn't convert nouns like 'realpart to their verb form.  For that,
try ev(%o3,nouns).  Does that do what you want?

-s

On Wed, Jun 6, 2012 at 12:31 PM, Henry Baker <hbaker1 at pipeline.com> wrote:

> Yes, but if I do the following, it doesn't work:
>
> (%i2) cabs(a)^2=realpart(a)^2+imagpart(a)^2;
>                           2           2              2
> (%o2)                abs(a)  = realpart (a) + imagpart (a)
> (%i3) %,a=r+%i*s;
>                      2           2                     2
> (%o3)       (%i s + r)  = realpart (%i s + r) + imagpart (%i s + r)
> (%i4) %,expand;
>          2               2           2                     2
> (%o4)  - s  + 2 %i r s + r  = realpart (%i s + r) + imagpart (%i s + r)
> (%i5) rectform(%);
>          2               2           2                     2
> (%o5)  - s  + 2 %i r s + r  = realpart (%i s + r) + imagpart (%i s + r)
>
> At 08:59 AM 6/6/2012, Richard Fateman wrote:
> >Henry:
> >
> >try this:
> >
> >a:  r+%i*s;
> >
> >cabs(a)^2= realpart(a)^2 + imagpart(a)^2;
> >
> >you can say declare(r,real); declare(s,real)  if you wish, but
> >it seems to be unnecessary.
> >
> >RJF
> >
> >On 6/6/12 8:37 AM, Stavros Macrakis wrote:
> >>I believe that cabs(a) used to return
> sqrt('realpart(a)^2+'imagpart(a)^2), though it now returns 'abs(a) (prints
> as |a|).  I think the former is more in the spirit of cabs (which is
> supposed to give you an explicit formula, not just punt to a nounform), so
> I would consider the current behavior to be a bug.
> >>
> >>If I remember correctly, a few years ago, someone tried to unify abs and
> cabs (I objected) -- this may be related to that?
> >>
> >>As a workaround, you can do cabs(rectform(a))^2 =>
> 'realpart(a)^2+'imagpart(a)^2.  Unfortunately, rectform(abs(a)) currently
> returns 'abs(a) -- again, I think this is a bug.  If you're starting with
> the abs form, I suppose you could do
> subst(lambda([ex],cabs(rectform(ex))),'abs, ... ).
> >>
> >>                 -s
> >>
> >>On Wed, Jun 6, 2012 at 11:06 AM, Henry Baker <hbaker1 at pipeline.com>
> wrote:
> >>I'm trying to get maxima to prove that
> >>
> >>abs(a)^2=realpart(a)^2+imagpart(a)^2.
> >>
> >>I tell maxima:
> >>
> >>declare(a,complex);
> >>abs(a)^2=realpart(a)^2+imagpart(a)^2;
> >>
> >>What do I tell maxima to get it to simplify this?
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>
-------------- next part --------------
An HTML attachment was scrubbed...