It might be useful to put together a table of the various cases: setting of
ratexpand, of domain, and the particular operations (default
simplification, rectform, etc.) to see what is consistent and what is
inconsistent, what is reasonable and what is unreasonable.
-s
On Sat, Sep 28, 2013 at 2:43 PM, John Lapeyre <lapeyre.math122a at gmail.com>wrote:
> On 09/28/2013 05:52 PM, Stavros Macrakis wrote:
> > On Fri, Sep 27, 2013 at 6:36 PM, Richard Fateman <fateman at gmail.com><fateman at gmail.com>wrote:
> >
> > ...
> >
> > As an example, (z^2)^(1/2) in Mathematica just stays the same.
> > I think that is better than what Maxima gives, which is abs(z).
> >
> >
> > This is under user control:
> >
> > radexpand:false => (z^2)^(1/2)
> > radexpand:true => abs(z)
> > radexpand:all => z
>
> There is also the following:
>
> (%i2) domain;
> (%o2) real
> (%i3) sqrt(z^2);
> (%o3) abs(z)
> (%i4) (z^2)^(1/2);
> (%o4) abs(z)
> (%i5) (z^3)^(1/3);
> (%o5) z
> (%i6) (-z^3)^(1/3);
> (%o6) -z
> (%i7) (-1)^(1/3);
> (%o7) -1
>
> Following is consistent with assuming
> (-x)^(1/3) --> - x^(1/3) for positive x
>
> (%i8) expr:sqrt((4*x^(1/3)-x^((-1)/3)/16)^2+1)$
> (%i9) float(integrate(expr,x,0,512)+integrate(expr,x,-8,0));
> (%o9) 12342.375
>
> (%i10) domain:'complex$
> (%i11) sqrt(z^2);
> (%o11) sqrt(z^2)
> (%i12) (z^2)^(1/2);
> (%o12) sqrt(z^2)
> (%i13) (z^3)^(1/3);
> (%o13) (z^3)^(1/3)
> (%i14) (-z^3)^(1/3);
> (%o14) (-z^3)^(1/3)
> (%i15) (-1)^(1/3);
> (%o15) (-1)^(1/3)
>
> Following is correct if we assume the ^(1/3) means
> the 'principle' cube root. This is what Mathematica,
> lisp, C, (Fortran?), etc. assume. (Note it can be done in
> one call with no questions asked.)
>
> (%i16) float(rectform(integrate(expr,x,-8,512)));
> (%o16) 41.24445985523388*%i+12318.1875
>
> The documentation for `domain' only mentions sqrt, so I assumed
> it had no effect on ^, but in fact it does. I don't know
> what to do in more complicated situations, where some quantities
> are complex and some are real and you want to reals mapped
> to reals.
>
> Then there is this:
>
> (%i1) domain:'real$
> (%i2) declare(z,complex)$
> (%i3) f(x):=sqrt((4*x^(1/3)-x^((-1)/3)/16)^2+1)$
>
> This makes sense.
>
> (%i4) (z^2)^(1/2);
> (%o4) sqrt(z^2)
>
> But, following chooses one root.
>
> (%i5) (z^3)^(1/3);
> (%o5) z
>
> Following, as before, assumes (-x)^(1/3) --> -(x)^(1/3)
> for postive x.
>
> (%i6) float(rectform(integrate(f(x),x,-8,0)))
> (%o6) 48.375
>
> Following is correct if we assume, with
> rest of the world, that sqrt means principle
> square root.
>
> (%i7) float(rectform(integrate(f(x),x,0,8)))
> (%o7) 48.375
>
> Following: I can't come up with an explantion for what
> maxima is thinking.
>
> (%i8) float(rectform(integrate(f(z),z,-8,0)))
> (%o8) -48.375
>
> Following is ok.
>
> (%i9) float(rectform(integrate(f(z),z,0,8)))
> (%o9) 48.375
>
> Following is reasonable. Setting domain
> to complex makes operations with z
> behave just as they would if we had
> not declared z complex.
>
> (%i10) domain:'complex
> (%i11) (z^2)^(1/2)
> (%o11) sqrt(z^2)
> (%i12) (-z^3)^(1/3)
> (%o12) (-z^3)^(1/3)
>
> Following all agree with standard
> definitions of principle square and cube roots.
>
> (%i13) float(rectform(integrate(f(x),x,-8,0)))
> (%o13) 41.24445985523388*%i+24.1875
>
> (%i14) float(rectform(integrate(f(x),x,0,8)))
> (%o14) 48.375
>
> (%i15) float(rectform(integrate(f(z),z,-8,0)))
> (%o15) 41.24445985523388*%i+24.1875
>
> (%i16) float(rectform(integrate(f(z),z,0,8)))
> (%o16) 48.375
>
> Likewise doing
> declare(z,real)$
> domain:'complex
> behaves the same as if we did not declare(z,real)$
>
> Another example:
>
> (%i2) domain:complex$
>
> The following gives a form which is always correct, but
> does not choose a root.
>
> (%i3) (-3)^(1/3);
> (%o3) (-1)^(1/3)*3^(1/3)
>
> Here the principle root of (3.0)^(1/3)
> is chosen, but that is not controversial.
>
> (%i4) (-3.0)^(1/3);
> (%o4) 1.442249570307408*(-1)^(1/3)
>
> rectform chooses the principle root
>
> (%i5) rectform((-1)^(1/3));
> (%o5) sqrt(3)*%i/2+1/2
>
>
> In summary, for the things I tried here: declare(z,complex) does not
> seem consistent. domain:complex, chooses standard definitions of
> principle roots and overrides declare. But, the
> principle root is chosen, more or less, only when a
> choice is forced.
>
> To at least some extent, Mathematica behaves
> as if domain:complex were in effect. It also
> does not choose a root on evaluating
> (-1)^(1/3). But ComplexExpand chooses the principle
> root, just as rectform does. Mathematica provides
> CubeRoot and Surd for getting the real roots, but
> this is only in the latest edition.
>
> --John
>
>