Pin the symbolic quadratic coefficient against regressing (#771) - #787
Merged
Merged
Conversation
#771 reported that integrating a quadratic in x^2 answers NaN as soon as the x^2 coefficient is a symbol, in the rational and the radical family alike -- the library saying a table integral has no antiderivative. Re-measured against master, none of it reproduces: PR #774 landed after the issue was filed and fixed all seven of its cases. What is missing is the coverage. #774's own tests do not reach the radical family, the squared-symbol forms, or the shape reached through a substitution, and those are three of the four families the issue names. Verified to have teeth rather than assumed to: run against 4ab9448, the commit before #774, sixteen of the eighteen cases fail; all eighteen pass on master. The two that do not fail there are radical cases whose specialised form was already right, which is why the symptom the issue actually reports -- the *symbolic* answer collapsing to NaN under Simplify -- is asserted separately. All seven of those fail before #774. Coefficients are substituted *after* the symbolic integration, never before. Specialising first measures the numeric-coefficient path, which was never broken, and is what hid this: the answer is a piecewise split on the sign of the symbolic coefficient, so what needs checking is that the branch selected for a given sign is the right one. Sampled rather than compared symbolically -- these antiderivatives are logarithms and arctangents of surds in the coefficients, and asserting a symbolic zero would test the simplifier's reach, not the integrator's answer. A point where either side leaves the reals is skipped, and the count of points actually compared is asserted to be non-zero so that a case cannot pass by having nothing to check. Test-only; 5426 pass, 0 fail. Co-Authored-By: Claude Opus 5 (1M context) <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.
Closes #771 — as already fixed, with the coverage it was missing.
#771 reported that integrating a quadratic in
x^2answersNaNas soon as thex^2coefficient is a symbol, in the rational and the radical family alike. Re-measured againstmaster, none of it reproduces: PR #774 landed after the issue was filed and fixed all seven of its cases.What is missing is the coverage. #774's own tests do not reach the radical family, the squared-symbol forms, or the shape reached through a substitution — three of the four families #771 names. This adds 18 cases that do.
Verified to have teeth
Not assumed. Run against
4ab9448c, the commit before #774:TheSymbolicAnswerCarriesNoNaNaloneThe two that do not fail on the old commit are radical cases whose specialised form was already right — which is exactly why the symptom the issue actually reports, the symbolic answer collapsing to
NaNunderSimplify, is asserted separately. One degenerate branch dividing by a literal zero is enough to take the whole piecewise with it.Two things the tests do deliberately
Coefficients are substituted after the symbolic integration, never before. Specialising first measures the numeric-coefficient path, which was never broken — and that is precisely what hid this. The answer is a
piecewisesplit on the sign of the symbolic coefficient, so what needs checking is that the branch selected for a given sign is the right one:Both signs of the symbolic coefficient and both signs of the constant are covered, since they select different branches.
Sampled rather than compared symbolically. These antiderivatives are logarithms and arctangents of surds in the coefficients; asserting a symbolic zero would test the simplifier's reach rather than the integrator's answer. A point where either side leaves the reals or goes infinite is skipped, and the number of points actually compared is asserted to be non-zero — so a case cannot pass by having had nothing to check.
Test-only change. 5426 pass, 0 fail.
🤖 Generated with Claude Code