simplification of number ^ number



Am Dienstag, den 05.10.2010, 10:05 -0400 schrieb Raymond Toy:
> On 10/5/10 8:22 AM, Barton Willis wrote:
> > The option variables domain, numer, numer_pbranch, and m1pbranch control the simplification of number^number.
> > These options are documented, but it's a mess; examples:
> >
> >  (%i40) block([domain : real, m1pbranch : false, numer_pbranch : false, numer : true], (-5.0)^(1/2));
> >  (%o40) 2.23606797749979*(-1)^0.5
> >
> >  (%i41) block([domain : real, m1pbranch : false, numer_pbranch : false, numer : false], (-5.0)^(1/2));
> >  (%o41) 2.23606797749979*%i
> This is really confusing!  I would have expected the opposite results,
> where numer:true would produce 2.236*%i.  Maybe numer is supposed to do
> that, but I find it confusing.
> 
> > The option variable m1pbranch controls the simplification of (-1)^x, but it's unclear to a user when (-1)^x
> > will be introduced into a calculation.
> >
> > You all might enjoy trying pow(-5,1/2), pow(-5.0, 1/2), pow(-5.0, 1/3), pow(-5.0, 0.333333333333), ...
> >
> > pow(x,y) := block([l : []],
> >   for d in ['real, 'complex] do (
> >    for n in [false, true] do (
> >      for pb in [false,true] do (
> >         for m1 in [false,true] do (
> >           block([domain : d, m1pbranch : m1, numer_pbranch : pb, numer : n], 
> >                 l : cons([x^y, domain, m1pbranch, numer_pbranch, numer],l)))))),
> >    l : cons(['(x^y),'domain, 'm1pbranch, 'numer_pbranch, 'numer],l),
> >    funmake('matrix, l))$
> >
> > I was thinking about the possibility of using the bigfloat package to do more evaluation of number^number.
> > But the 16 values for domain, numer, numer_pbranch, and m1pbranch make it complicated.
> Perhaps it's finally time to sit and think and rationalize all of
> these.  I think there are several bug reports about how float() and
> numer : true produce confusing results.
> 
> Ray

The problem is not the flag numer. The problem is in simpexpt and
especially in exptrl. simpexpt does not consequently simplify to
numerical values, but introduces expression like (-1)^number and
(-float)^number. For the sqrt function and the exp function we have
special hacks to simplify to a number. This causes inconsistencies too,
e.g.

(%i1) (-2.0)^(1/2);
(%o1) 1.414213562373095*%i

(%i2) (-2.0)^(0.5);
(%o2) (-2.0)^0.5

If we would consequently simplify to a number (the principal value) most
of the problems with floating point and bigfloat numbers will vanish.

Dieter Kaiser