I have just checked and JE already does treat _0. as negative zero:
% _0.
__
It is hard to keep -0 through a calculation. Whenever you add it to a
nonnegative number it acts like 0. If all you do is multiply and divide
you can keep the negative zero, with the exception that +-0 % +-0 gives +0.
Henry Rich
On 7/30/2023 3:26 PM, Henry Rich wrote:
You have found an error, I think. We were /not/ using Kahan's formula
and branch cuts. (Our version came from Abramowitz & Stegun)
William Kahan is a mighty man. On his authority (and the sources you
cited) I have changed to his formulas for arctanh/arctan. I have not
checked his other 7 formulas.
-0 was problematic. You can create a float -0 but I couldn't find a
way to make that the real part of a complex value.
m0 =. 1 % __
% m0
__
% +. m0 j. 0 NB. should be __ _
_ _
This was because (x j. y) did a complex multiply, which used addition,
which wiped out the -0.
I have now modified (x j. y) so that it avoids the multiplication when
given real arguments. Now
% +. m0 j. 0
__ _
That revealed the problem you point out in this post:
_3 o. _1e_100 j. 1e10
_1.5708j1e_10
_3 o. m0 j. 1e10
1.5708j1e_10
I fixed that as well. Now
_3 o. m0 j. 1e10
_1.5708j1e_10
I also fixed it so that if either component is large, the result is
+-pi/2, avoiding the previous NaN errors.
These fixes will go out either in the imminent next beta or the one
after that.
Perhaps we should take _0. to mean negative zero. I don't see a good
reason not to.
Henry Rich
On 7/29/2023 7:05 PM, LdBeth wrote:
Actually, the current J atan/atanh implementation ignores the sign of
real part when the complex part goes infinity. While in Chez or CCL
the sign of real component is use for the result:
|> (atan 0.0+1e18i) 1.5707963267948966+0.0i > (atan -0.0+1e18i)
-1.5707963267948966+0.0i |
|_3 o. _1.0j_1e18 1.5708 _3 o. 1.0j_1e18 1.5708 |
This also comes to the notorious signed zero problem. I know J does
not differentiate pos zero and neg zero. There is really a design
choice need to be made for the problem.
—
Reply to this email directly, view it on GitHub
<https://github.com/jsoftware/jsource/issues/180#issuecomment-1656947906>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEKVAJ2OFK2CG5GKBD7BKBDXSWJNNANCNFSM6AAAAAA2ZSCW2Q>.
You are receiving this because you are subscribed to this
thread.Message ID: <jsoftware/jsource/issues/180/[email protected]>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm