Skip to content

Pin the symbolic quadratic coefficient against regressing (#771) - #787

Merged
Rafael-SOWNet merged 1 commit into
masterfrom
fix/771-symbolic-quadratic-coefficient
Aug 7, 2026
Merged

Pin the symbolic quadratic coefficient against regressing (#771)#787
Rafael-SOWNet merged 1 commit into
masterfrom
fix/771-symbolic-quadratic-coefficient

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Collaborator

Closes #771 — as already fixed, with the coverage it was missing.

#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. 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 — 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:

before #774 on master
all cases 16 of 18 fail 18 pass
TheSymbolicAnswerCarriesNoNaN alone 7 of 7 fail 7 pass

The 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 NaN under Simplify, 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 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:

var antiderivative = integrand.ToEntity().Integrate("x");   // symbolic first
var specialised = antiderivative.Substitute("b", 2.0).Substitute("a", 3.0).Simplify();
// then differentiate back and sample

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

#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>
@Rafael-SOWNet
Rafael-SOWNet merged commit f4c6466 into master Aug 7, 2026
24 checks passed
@Rafael-SOWNet
Rafael-SOWNet deleted the fix/771-symbolic-quadratic-coefficient branch August 7, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate answers NaN for 1/(a + b*x^2) when the x^2 coefficient is symbolic

1 participant