bfloat(sqrt(%i))?



Am Montag, den 07.06.2010, 17:57 -0400 schrieb Raymond Toy:
> Currently maxima says bfloat(sqrt(%i)) is 1b0*(-1)^(1/4).  That doesn't
> seem very nice.  I was expecting something along the lines of
> bfloat(rectform(sqrt(%i))) -> .707b0 + %i*.707b0.

That is the case for float too:

(%i6) float(sqrt(%i));
(%o6) 1.0*(-1)^(1/4)

This is because Maxima simplifies:

(%i7) sqrt(%i);
(%o7) (-1)^(1/4)

We get numerical values the following way:

(%i8) sqrt(1.0*%i);
(%o8) .7071067811865475*%i+.7071067811865476
(%i9) sqrt(1.0b0*%i);
(%o9) 7.071067811865475b-1*%i+7.071067811865475b-1

But not when we use numer, float or bfloat:

(%i10) sqrt(%i),float;
(%o10) (-1)^0.25

(%i11) sqrt(%i),numer;
(%o11) 1.0*(-1)^0.25

(%i12) sqrt(%i),bfloat;
(%o12) 1.0b0*(-1)^(1/4)

We have similar problems with all even powers:

(%i1) float((%i)^(1/6));
(%o1) 1.0*(-1)^(1/12)
(%i2) bfloat((%i)^(1/6));
(%o2) 1.0b0*(-1)^(1/12)

More problems with (-1):

(%i4) (sqrt(-1)),numer;
(%o4) 1.0*(-1)^0.5

(%i5) float(sqrt(-1));
(%o5) %i

(%i6) sqrt(-1),bfloat;
(%o6) %i

When we go into the details we will see two problems:

Maxima does not follow the convention to evaluate numerically the power
function if one of the arguments is a float or bigfloat value.

Maxima does not preserve the type consequently.

Dieter Kaiser