Take a repeated rational root out of a denominator all at once - #871
Merged
Rafael-SOWNet merged 1 commit intoAug 10, 2026
Merged
Conversation
TrySplitOffRationalRoot divided one factor of (x - r) out of the denominator and gave up
if the quotient still vanished there, with the comment "repeated root". So a denominator
whose only rational root is a repeated one was never split at all: 1/(x^4 + x^2) had no
antiderivative, though x^4 + x^2 is x^2(x^2 + 1) and the decomposition is 1/x^2 minus
1/(x^2 + 1).
A root of multiplicity m contributes a term over the m-th power rather than the first, so
the fix is to divide the root out as many times as it goes and use the power that came out.
What was already there is this with m fixed at 1. One degree still comes off the denominator
each step, so it terminates for the reason the single-root case did.
1 / (x^4 + x^2) no antiderivative -> solved
1 / (x^3 + x^2) no antiderivative -> solved
1 / ((x - 1)^2 * (x + 2)) no antiderivative -> solved
1 / ((x + 1)^3 * (x - 2)) no antiderivative -> solved
x / ((x - 1)^2 * (x^2 + 1)) no antiderivative -> solved
(x + 1) / (x^3 - x^2) no antiderivative -> solved
Every one checked by differentiating the answer back and comparing at points, so a wrong
antiderivative cannot pass as a solved one. The single-root cases that worked before still
do, and propcheck is unchanged at 1340 checks with no failures.
Denominators with no rational root at all remain out of reach -- x^4 + 1 is irreducible
over Q and only factors once real coefficients are allowed. There is a test asserting that
too, so the boundary is visible rather than inferred from an absence.
Verified: 6118 C# tests and 130 F# tests pass.
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.
TrySplitOffRationalRootdivided one factor of(x - r)out of the denominator and gave up if the quotient still vanished there — the code said so plainly:So a denominator whose only rational root is a repeated one was never split at all.
1/(x^4 + x^2)had no antiderivative, thoughx^4 + x^2isx^2(x^2 + 1)and the decomposition is just1/x^2 - 1/(x^2 + 1).The fix
A root of multiplicity m contributes a term over the m-th power rather than the first. So divide the root out as many times as it goes, and use the power that came out. What was already there is this with m fixed at 1 — one degree still comes off the denominator each step, so it terminates for exactly the reason the single-root case did.
1 / (x^4 + x^2)1 / (x^3 + x^2)1 / (x^2 * (x + 1))1 / ((x - 1)^2 * (x + 2))1 / ((x + 1)^3 * (x - 2))x / ((x - 1)^2 * (x^2 + 1))(x + 1) / (x^3 - x^2)Every one is checked by differentiating the answer back and comparing at points, so a wrong antiderivative cannot pass as a solved one. That is the existing
AssertIsAntiderivativehelper in the file, reused rather than reinvented.How it was found
Not by reading the code. Running the
casbenchcorpus against master leftx^2/(x^4 + 1)unsolved, and while probing what was and was not reachable around it,1/(x^4 + x^2)turned up — a denominator that factors overQand still had no answer. The corpus had no repeated-root case at all, which is why this went unnoticed; four have been added.The boundary, asserted rather than implied
Denominators with no rational root stay out of reach:
x^4 + 1is irreducible overQand only factors once real coefficients are allowed, which needs partial fractions with algebraic coefficients. There is now a test asserting those are declined, so the edge is visible in the suite instead of inferred from an absence.Worth recording: the pieces past that edge already work.
(x + 1)/(x^2 - sqrt(2)*x + 1)and1/(x^2 - sqrt(2)*x + 1)both integrate in 2 ms, so forx^4 + 1the only missing step is the factorisation itself.Verification
propcheck: 1340 property checks, 0 failures — unchangedcasbench: 117/119 of the problems with an elementary answer, up from 113/115 with the four new cases🤖 Generated with Claude Code