Repository navigation
A compiled odd root of a negative real is real - #2318
Merged
Rafael-SOWNet merged 1 commit intoNov 1, 2026
Merged
Conversation
Evaluation takes a negative real to a rational power whose denominator is odd and below ten as the real root to the numerator, Number.Pow's search for a good root finding it: (-8)^(1/3) is -2 and (-8)^(2/3) is 4. Both compilers took the principal power, 1 + 1.73i and -2 + 3.46i, and Compile<double, double> took Math.Pow, which is NaN there. Whether the exponent is such a rational is known only where the power is written, so each compiler now chooses, as it compiles a power to one, RealProducts.RealRootPower: the real root to the numerator for a negative real base, the power as before for any other. Newton's method, which Solve falls back to, runs on the compiled function, so the roots that need the real root were not found: (3 - 4x)^(1/3) + sqrt(4 + 4x) = 3 was answered without 8.379, (1 + x)^(1/3) + sqrt(-1 - 2x) = 4 + 2x without -1.672, and (-4x)^(1/3) + sqrt(2 + 2x) = 3 without 30.81. Each is found now. Found by a cross-check of equations in square and cube roots against a Newton search. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2318 +/- ##
=======================================
Coverage 86.77% 86.78%
=======================================
Files 311 311
Lines 68216 68241 +25
Branches 19827 19833 +6
=======================================
+ Hits 59197 59220 +23
Misses 4878 4878
- Partials 4141 4143 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Rafael-SOWNet
deleted the
a-compiled-odd-root-of-a-negative-real-is-real
branch
November 1, 2026 19:02
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.
Evaluation takes a negative real to a rational power with an odd denominator below ten as the real root to the numerator:
Number.Pow's search for a good root finds it, so(-8)^(1/3)is-2and(-8)^(2/3)is4. Both compilers took the principal power instead, andCompile<double, double>tookMath.Pow, which isNaNthere. Whether the exponent is such a rational is known only where the power is written, so each compiler now makes that choice as it compiles a power:RealProducts.RealRootPowertakes the real root to the numerator for a negative real base, and the power as before for any other.x = -8x^(1/3)-2<1; 1.73>;NaNoverdouble-2x^(2/3)4<-2; 3.46>4x^(-1/3)-1/2<0.25; -0.43>-1/2Solvefalls back to, runs on the compiled function, so roots that need the real root weren't found. Each of these is now:(3 - 4x)^(1/3) + sqrt(4 + 4x) = 3was missing 8.379;(1 + x)^(1/3) + sqrt(-1 - 2x) = 4 + 2xwas missing -1.672;(-4x)^(1/3) + sqrt(2 + 2x) = 3was missing 30.81.sqrt(-4)is still2i), and a denominator of ten or more ((-1)^(1/11)is principal).BREAKING-CHANGES.mdhas an entry.No issue was filed.
🤖 Generated with Claude Code