float evaluation of erfi



On 2012-12-02, Raymond Toy <toy.raymond at gmail.com> wrote:

> For a < 0, we have z = |a|*exp(-%i*%pi/2), so
> sqrt(z^2) = sqrt(|a|^2*exp(+%i*%pi)) = |a|*exp(+%i*%pi/2).  Thus
> sqrt(z^2) = |a|*exp(+%i*%pi/2)/(a*exp(-%i*%pi/2)) = |a|/a *exp(%i*%pi)
>= 1.

I dunno -- isn't z = -i a counterexample to that?

> CMUCL has no such flag.  And since IEEE754 requires signed-zeroes it,
> the only way to work around it is to add 0 to the result. (Because
> -0.0 + 0.0 is required to be +0.0.)

Well, I see the usefulness of signed zero, but in CL-land we have to
live without it, so if it makes a difference in a computation, we have
to suppress it (unless we put in appropriate #+foo #-foo ...).

> I have a much simpler solution to erfi(-0.15).  erfi is an odd
> function, so compute erfi(-z) as -erfi(z).  

Well, I wouldn't put that logic in erfi since erf and erfc will run into
the same problem. But putting it in erf is problematic -- the condition
has to be "if Im(z) < 0 then conj(erf(conj(z))) else ..." or something
like that -- it seems clumsy, but maybe it's no big deal. Maybe that's
preferable to (+ (EXPT Z 2) #C(0.0 0.0)) which is its own kind of
clumsiness.

best

Robert Dodier