Am Donnerstag, den 07.01.2010, 17:13 -0500 schrieb Stavros Macrakis:
> On Thu, Jan 7, 2010 at 4:57 PM, Stanislav Maslovski
> <stanislav.maslovski at gmail.com> wrote:
> On Thu, Jan 07, 2010 at 10:01:35AM -0500, Stavros Macrakis
> wrote:
> > The approach using "cabs" is probably not ideal.
> >
> > The purpose of cabs is to produce a *symbolic expression*
> for the complex
> > absolute value.
>
>
> In what sense exactly is it different from myabs(z) :=
> sqrt(realpart(z)^2 + imagpart(z)^2)?
>
> It does not necessarily give an answer in that form. For example,
> cabs(exp(%i*x)) => 1, but myabs(exp(%i*x)) => sqrt(sin(x)^2+cos(x)^2),
> which of course is equal to 1, but is not simplified to 1.
>
> The documentation is unclear.
>
> Unclear about what in particular?
>
>
> By experimentation I see that all 3 functions return same
> symbolic answers if given a symbolic expression.
>
> The fact that abs(x) gives the same result as cabs(x) is a recent, um,
> innovation (OK, frankly, I consider it a bug), which was apparently
> introduced by an implementor who didn't understand the rationale
> behind abs and cabs being different. I can understand how that might
> happen, since the documentation does not distinguish clearly between
> abs and cabs.
I am looking at this problem and I try to work out the underlying
problem. But I have one remark, because I have worked on the functions
for the complex components.
The call of cabs from the code of simpabs is present since the initial
revision with the date 08.05.2000. This is the piece of code from the
initial revision:
(DEFMFUN SIMPABS (X Y Z)
(ONEARGCHECK X)
(SETQ Y (SIMPCHECK (CADR X) Z))
(COND ((NUMBERP Y) (ABS Y))
((OR (RATNUMP Y) ($BFLOATP Y)) (LIST (CAR Y) (ABS (CADR Y)) (CADDR
Y)))
((EQ (SETQ Z (CSIGN Y)) T) (CABS Y))
...
This code does the following: Every time simpabs detects the imaginary
unit %i in the expression the function cabs is called. This is the case
for the example of the reported problem too.
Therefore, this piece of code and the call of cabs from simpabs is not a
recent innovation. If it is a bug to call cabs from abs, then this bug
is present since the initial revision of Maxima.
The implementation of this part of code has changed. The main change is
that the test csign has been replaced by $csign which is a bit stronger,
e. g. it detects symbols declared to be complex in addition. Some
problems vanished because of this change, e.g. with the old code and z
declared to be complex we get abs(sqrt(z)) -> sqrt(z) (wrong for a
complex symbol), the result for the new code after the change of simpabs
is abs(sqrt(z)) -> sqrt(abs(z)).
Nevertheless, there is a problem for the reported example. The algorithm
of rectform that is trisplit works well for this example, but not the
algorithm of absarg.
Remark: It might be interesting to see what will happen if we cut out
the call of cabs completely from simpabs. I will try it.
Dieter Kaiser