float bigfloat complex numbers



On 09/30/2013 06:04 AM, Richard Fateman wrote:
>  Anyway, I think that's why something like
>
>  Q: exp(1/3*(log(2)+2*%pi*%i))
>
>  Q,numer
>  Q,float
>  Also there seems to be some inhibition to just calling expand or 
rectform on
>  numeric items "automatically" because maybe that's not what you want??

That's essentially what I want, to have float() call rectform, because
rectform chooses a root. And it chooses the same root that lisp,
C, Mathematica, (Maple, fortran ... ?) etc. choose when asked to
return a floating point number--- modulo the quirky domain:real, which
chooses a different root under certain circumstances. My proposed
change respects (automatically, not explicitly, domain:real), but
apart from that agrees with Mathematica's N[].

By the way, this compares  ev flat float
ev flag numer , float() and lisp. Only ev flag float
does not do a conversion.

(%i2) log(%i+1),numer;
(%o2) .7853981633974483*%i+.3465735902799726
(%i3) log(%i+1),float;
(%o3) log(%i+1)
(%i4) float(log(%i+1));
(%o4) .7853981633974483*%i+.3465735902799726
(%i5) :lisp (log #C(1 1))

#C(0.3465736f0 0.7853982f0)

The floating point results choose the principal branch
for the log: the imaginary part is between -%pi and %pi.

I don't know what to say about the flags, but I'd like float() to also
choose the principal root (or the domain:real thing) for exponents.
The only way I know to do this now is write something that scans an
expression and does some logic and calls rectform and float (sometimes
twice) where it finds roots. rectform is already applied
recursively, but that's not fine-grained enough because
rectform(f(x)) --> realpart(f(x)) + %i * imagpart(f(x))

I suppose one could add another global flag or use an
existing one to toggle the proposed behavior.