You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5d4a300
Browse filesBrowse the repository at this point in the historyBrowse files
A compiled function takes the side of its branch cut evaluation takes (#2240)
System.Numerics.Complex computes -0 as a part of many real values.
cos(2) is (cos 2, -sin 2 * sinh 0), which is (-0.416, -0), and
conj(-2) is (-2, -0). Complex.Log, Complex.Sqrt and the inverse
functions read a -0 as the lower side of the negative real axis. The
library has no signed zero, so a real number is on the upper side. So in
both compilers, ln(cos(x)) at 2 was -0.8767 - pi i where evaluation gives
-0.8767 + pi i, and sqrt(conj(x)) at -4 was -2i.
ComplexBranches.Unsigned reads each zero part as +0, by adding +0.0,
which turns -0 into +0 and changes no other number. It is taken at the
entry of every compiled function with a cut, in FastExpression and in
MathAllMethods:
- the logarithm;
- a power that is not whole, in RealProducts.Power;
- arcsin, arccos, arctan, arccotan, arcsec and arccosec;
- arg;
- the exponential and logarithmic integrals;
- lambertw.
ComplexBranches.Arcsin already conjugated on its cut, and now does so
from the +0 side, which is what it was written for.
FastExpression's logarithm was Complex.Log(value, base.Real), whose base
parameter is a double, so a complex base lost its imaginary part:
log(x, 2) at 1 + i was NaN. It is ComplexBranches.Log now,
ln(value) / ln(base), as the LINQ compiler already took it (#2239).
BranchCutCompilationTest takes each of the 19 functions at 11 real
points, with its argument written three ways that land on a cut: conj(x),
cos(x) and i * x. It compares both compilers with evaluation, and adds
three logarithms to complex bases. 9 of its 22 cases fail on master. A
pole is left out, since there the infinity has a NaN part, which is not
what this is about. So is an exponent with an odd denominator, where
evaluation takes the real root, which a double exponent cannot show.
Fixes#2236. Fixes#2239.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
0 commit comments