>>>>> "Robert" == Robert Dodier <robert.dodier at gmail.com> writes:
Robert> 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.
Robert> I dunno -- isn't z = -i a counterexample to that?
See my reply to Jaime. With signed zeroes z = -i = +0 - i, so things
work out differently and are easier to reason about, at least in this
case.
>> 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.)
Robert> Well, I see the usefulness of signed zero, but in CL-land we have to
Robert> live without it, so if it makes a difference in a computation, we have
Robert> to suppress it (unless we put in appropriate #+foo #-foo ...).
CL doesn't forbid signed zeroes. Any CL that uses the IEEE754
hardware will get signed zeroes whether you want it or not. In fact,
for lisps that "don't" support signed zeroes, I think the only real
issue is that the lisp printer and reader doesn't support signed
zeroes. If that's changed, you get signed zeroes automatically,
because the hardware has it.
(At least, I'm not aware of any lisp that goes out of it's way to
smash the signed zero produced by hardware.)
>> I have a much simpler solution to erfi(-0.15). erfi is an odd
>> function, so compute erfi(-z) as -erfi(z).
Robert> Well, I wouldn't put that logic in erfi since erf and erfc will run into
Robert> the same problem. But putting it in erf is problematic -- the condition
Actually, I tend to prefer such things. It makes sure that
mathematical identities like erfi(-x) = -erfi(x) remain true
numerically.
Your point about erf still stands though. I don't have any solution
right now.
Ray
Footnotes:
[1] The spec says