Repository navigation
A compiled product of real numbers is real at an infinity - #2226
Merged
Merged
Conversation
Over System.Numerics.Complex, in FastExpression and in the LINQ compiler, a product's imaginary part is a.Re b.Im + a.Im b.Re. With a real infinity that is inf * 0, which is NaN. So -x at +oo was (-inf, NaN), and so were 2 * x, x / 2 and x * x. That is a value with no imaginary part at all, so a comparison of it had no truth value and a piecewise passed over it. Evaluation gives -oo, and so does the compiler over double. RealProducts.Product and Quotient take two numbers whose imaginary parts are both 0 as reals, and anything else as before. FastExpression's CALL_MUL and CALL_DIV call them, and so does the LINQ compiler's Multiply and Divide over Complex. A division by 0 is left to Complex, whose NaN is evaluation's. A real Quotient would have made 1/x at 0 +inf, where evaluation has no value for 1/0. MembershipCompilationTest's piecewise case, which #2223 kept away from the infinities for this, now runs at +oo and -oo as well. RealProductCompilationTest: 8 expressions at +oo or -oo, all failing on master, and 6 elsewhere that keep their values: a division by 0, and complex products and quotients. A power at a real infinity is NaN in both parts, which is a different mechanism, Complex.Pow. It is #2225. Fixes #2222. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2226 +/- ##
==========================================
- Coverage 86.67% 86.66% -0.02%
==========================================
Files 308 309 +1
Lines 67639 67644 +5
Branches 19610 19612 +2
==========================================
- Hits 58628 58625 -3
- Misses 4895 4899 +4
- Partials 4116 4120 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2222.
Over
System.Numerics.Complex, in FastExpression and in the LINQ compiler, a product's imaginary part isa.Re b.Im + a.Im b.Re. With a real infinity that is∞ · 0, which isNaN. So-xat+oowas(-∞, NaN), and so were2 * x,x / 2andx * x. That is a value with no imaginary part at all: a comparison of it had no truth value, and apiecewisepassed over it. Evaluation gives-oo, and so does the compiler overdouble.RealProducts.ProductandRealProducts.Quotienttake two numbers whose imaginary parts are both0as reals, and anything else as before. FastExpression'sCALL_MULandCALL_DIVcall them, and so do the LINQ compiler'sMultiplyandDivideoverComplex.A division by
0is left toComplex, whoseNaNis evaluation's. A real quotient would have made1/xat0equal+∞, where evaluation has no value for1/0."-x".ToEntity().Compile("x").Call(double.PositiveInfinity)(-Infinity, NaN)(-Infinity, 0)"x / 2".ToEntity().Compile<Complex, Complex>("x")(double.PositiveInfinity)(Infinity, NaN)(Infinity, 0)#2223's
MembershipCompilationTestkept itspiecewisecase away from the infinities because of this. That case now runs at+ooand-ootoo.Tests:
RealProductCompilationTesthas 8 expressions at+ooor-oo, all failing on master. It also has 6 cases elsewhere that keep their values: a division by0, and complex products and quotients. Full suite 18025/0, interactive trio, AOT smoke 73/0, all frameworks build.A power at a real infinity comes out
NaNin both parts. That is a different mechanism,Complex.Pow, filed as #2225.🤖 Generated with Claude Code