Hi,
I have a suggested patch for bfloat() and float().
Currently they don't reduce some expressions as
far as they could. These expressions involve
roots or products of complex numbers.
(following is all with domain:complex, but
domain:real shows similar behavior)
Currently, we have this:
(%i2) float((3+%i)^(1/3));
(%o2) (%i+3.0)^(1/3)
But, the principle branch of the log is chosen.
(%i3) float(log(3+%i));
(%o3) .3217505543966422*%i+1.151292546497023
There also is an inconsistency between float
and bfloat. Notice that in one case,
bfloat converts an exponent.
(%i5) float((3+%i)^(%i/3));
(%o5) (%i+3.0)^(%i/3)
(%i6) bfloat((3+%i)^(%i/3));
(%o6) (%i+3.0b0)^(%i/3)
(%i7) bfloat((3)^(%i/3));
(%o7) 3.0b0^(3.333333333333333b-1*%i)
(%i8) float((3)^(%i/3));
(%o8) 3.0^(%i/3)
Here is an example where a product of complex numbers are not
multiplied (I'm sure there is a more minimal example)
expr : -%e^-1*gamma_incomplete(2/3,-1)/(-1)^(2/3)
-(-1)^(2/3)*%e^-1*gamma(2/3)-(-1)^(1/3)*%e^-1*gamma(2/3);
float(rectform(expr));
-->
%i*(-.3678794411714423*(-0.25*%i
*(2.029609422903235*%i
-1.0
*(2.525913486089384
-2.029609422903235*%i)
+2.525913486089384)
-2.187505246715117)
-.8628248351483758)
-.3678794411714423*(.4330127018922193*%i
*(2.029609422903235*%i
-1.0
*(2.525913486089384
-2.029609422903235*%i)
+2.525913486089384)
-1.262956743044692)
I have a patch that gives x + %i * y with
x and y floats or bfloats in each of the cases above
(and every case I could find).
I don't think it is a conceptual change since many
multivalued complex functions already return a number
with float and bfloat.
The new code could probably be optimized more than
it is.
The entire test suite passes with this patch.
--John