Repository navigation
A compiled power of real numbers is the real power, at an infinity and at zero - #2231
Merged
Merged
Conversation
…d at zero In FastExpression and in the LINQ compiler over Complex, a power was Complex.Pow, which takes e^(b ln a). At an infinite base that brings in inf * 0, so x^2, x^3, sqrt(x) and exp(-x) at an infinity were (NaN, NaN), where evaluation gives +oo, -oo or 0. And it gave 0 for 0^(-1) and 1 for 0^0, where evaluation has no value for either. RealProducts.Power is now the power in both compilers, through FastExpression's CALL_POW and MathAllMethods.Pow over Complex: - a real power where there is one, a positive base or a negative one to a whole power, by Math.Pow, and by Math.Sqrt for an exponent of 1/2; - 0 to a positive power is 0, and 0 to any other power has no value; - NaN where either side is NaN; - Complex.Pow for anything else, as before. That includes a negative base to a power that is not whole, whose principal value differs from evaluation's real root for an odd denominator. A double exponent cannot show that denominator. At finite positive points nothing moves. Complex.Pow already equals Math.Pow at all 100000 random points of (0, 100) x (-5, 5) measured. RealPowerCompilationTest compares both compilers with evaluation over 10 real bases by 11 exponents, among them 0, the infinities and fractions. It also covers six expressions at an infinity and three complex powers that stay principal. 7 of its 10 cases fail on master. Fixes #2225. 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 #2231 +/- ##
==========================================
- Coverage 86.68% 86.66% -0.02%
==========================================
Files 310 310
Lines 67679 67691 +12
Branches 19627 19634 +7
==========================================
- Hits 58668 58665 -3
- Misses 4894 4908 +14
- Partials 4117 4118 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This was referenced Oct 30, 2026
Closed
Rafael-SOWNet
added a commit
that referenced
this pull request
Nov 2, 2026
m_1 sqrt(A) + m_2 sqrt(B) + P = 0 with two different square roots was not raised at all, and went to Newton's method, which cannot reach a root where a radicand is 0. sqrt(-4 - 4x) + sqrt(2 + x) = -3 - 4x was answered without its root -1. 2.6.0 found that root only because a compiled 0^(-1/2) was 0, so Newton's step from -1 was 0; since #2231 made it NaN, the root has been missed, and sqrt(2x + 3) - sqrt(x + 1) = 1 lost its root -1 with it. It is now squared twice, 4 P^2 m_2^2 B = (m_1^2 A - P^2 - m_2^2 B)^2, which keeps every root, and each root of that polynomial is put back into the equation as for one radical. Only for an equation in x alone: with a parameter left in, a root put back cannot be decided, and sqrt(x + 1) + sqrt(x + 2) + a + x = 0 kept all four roots of its square. radcheck, random radical equations, unsolved on master and here: seed 61, 26 and 5 of 400; seed 51, 31 and 7; seed 22, 24 and 3; seed 62 (pow), 0 and 0 of 600. No root is unsound and none missed but one that is not a root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 #2225.
In FastExpression and in the LINQ compiler over
Complex, a power wasComplex.Pow, which takese^(b ln a). At an infinite base that brings in∞ · 0, sox^2,x^3,sqrt(x)andexp(-x)at an infinity were(NaN, NaN), where evaluation gives+oo,-ooor0. It also gave0for0^(-1)and1for0^0, where evaluation has no value for either.RealProducts.Poweris now the power in both compilers, through FastExpression'sCALL_POWandMathAllMethods.PowoverComplex:Math.Pow, or fromMath.Sqrtfor an exponent of1/2.0to a positive power is0, and0to any other power has no value.NaNon either side givesNaN.Complex.Pow, as before. That includes a negative base to a power that is not whole. Its principal value differs from evaluation's real root for an odd denominator, which a double exponent cannot show."x^2".ToEntity().Compile("x").Call(double.PositiveInfinity)(NaN, NaN)(Infinity, 0)"x^(-1)".ToEntity().Compile("x").Call(0)(0, 0)(NaN, 0)"x^0".ToEntity().Compile("x").Call(0)(1, 0)(NaN, 0)At finite positive points nothing moves.
Complex.Powalready equalsMath.Powat all 100,000 random points of(0, 100) × (-5, 5)measured, so the accuracy question raised on #2225 does not arise.Tests:
RealPowerCompilationTestcompares both compilers with evaluation over 10 real bases by 11 exponents, among them0, the infinities and fractions. It also covers six expressions at an infinity and three complex powers that stay principal. 7 of its 10 cases fail on master. Full suite 18070/0, interactive trio, AOT smoke 73/0, all frameworks build.🤖 Generated with Claude Code