complex expressions



Ah, the problem here has nothing to do with cabs.  It is the general
simplifier that blindly and incorrectly transforms 'abs(EX)^2 => EX^2,
assuming (without checking) that EX is real.

              -s

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

> Yes, it work, but only _after_ I defined my own absolute value function.
>  See my previous message.
>
> At 10:22 AM 6/6/2012, Stavros Macrakis wrote:
> >What exactly do you consider "hopelessly broken" in this? In other words,
> which of these outputs would you want to be different, and what would you
> want them to be?
> >
> >            -s
> >
> >On Wed, Jun 6, 2012 at 12:52 PM, Henry Baker <hbaker1 at pipeline.com>
> wrote:
> >cabs() and abs() on complex numbers seem hopelessly broken.
> >
> >I defined my own cabs() function:
> >myabs(a):=sqrt(a*conjugate(a));
> >
> >(%i7) myabs(a)^2=realpart(a)^2+imagpart(a)^2;
> >                                         2              2
> >(%o7)            a conjugate(a) = realpart (a) + imagpart (a)
> >(%i8) %,nouns;
> >                                         2              2
> >(%o8)            a conjugate(a) = realpart (a) + imagpart (a)
> >(%i9) %,a=ar+%i*ay;
> >                                         2                       2
> >(%o9) (ar - %i ay) (%i ay + ar) = realpart (%i ay + ar) + imagpart (%i ay
> + ar)
> >(%i10) %,expand;
> >            2     2           2                       2
> >(%o10)     ay  + ar  = realpart (%i ay + ar) + imagpart (%i ay + ar)
> >(%i11) %,rectform;
> >            2     2           2                       2
> >(%o11)     ay  + ar  = realpart (%i ay + ar) + imagpart (%i ay + ar)
> >(%i12) %,nouns;
> >                              2     2     2     2
> >(%o12)                       ay  + ar  = ay  + ar
> >
> >
> >At 09:31 AM 6/6/2012, Henry Baker 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?
>
>