Skip to content

Split a definite integral at an equation's solutions and at exact points (#2654) - #2657

Open
Rafael-SOWNet wants to merge 1 commit into
masterfrom
equation-thresholds-2654
Open

Rafael-SOWNet wants to merge 1 commit into
masterfrom
equation-thresholds-2654

Conversation

@Rafael-SOWNet

Copy link
Copy Markdown
Member

This PR fixes how a definite integral of a piecewise or provided expression is split at the boundaries of its conditions. Three things were wrong:

  • Equation boundaries were not read. Only a comparison of the variable with a number counted as a boundary. (x^3 - x)/(x^2 - 1) simplifies to x provided not x^2 - 1 = 0, so its integral over [-2, 2] was left unevaluated, even though the condition fails only at ±1 and the integral is 0.
  • Infinite ranges were not split. A range with an infinite bound was not split at all.
  • Boundaries became decimals. A boundary went into the pieces as a decimal, so a split at sqrt(2) gave 3 - 1.41421….

The fix:

  • Equation solutions: these are now boundaries, listed by AntiderivativeBreaks.ZerosOf, the lister the antiderivative breaks already use. It handles periodic families such as cos(x) = 0.
  • Infinite bounds: a range with an infinite bound is split like a finite one. Each outer piece is sampled one unit inside its finite end.
  • Exact points: each boundary is kept as written, so the pieces end at exact points.
  • Unchanged case: a condition that fails on an interval still leaves no value there.
simplified 2.10.0 / master this branch
integral((x^3 - x)/(x^2 - 1), x, -2, 2) unevaluated 0
integral(sin(x) cos(x)^0, x, 0, pi) unevaluated 2
integral(sin(x)^4 cos(x)^0, x, 0, pi) unevaluated 3/8 * pi
integral((-x - 1)/(x^3 + 3x^2 + x - 1), x, -oo, -3) unevaluated closed form = -0.623225240140230513… (mpmath)
integral(piecewise(x provided x < sqrt(2), 1), x, 0, 2) 3 - 1.41421… (a 100-digit decimal) 3 - sqrt(2)
integral(x provided x > 1/2, x, 0, 1) unevaluated unevaluated

Checks

  • Sweep: 162 new integrands: trig × exp, hyperbolic × polynomial, sin^m cos^n with odd and even exponents, and definite integrals with a symbolic parameter checked at three values. Run alongside the earlier exp/ln/radical and rational sets, 622 cases in all: 0 wrong.
  • Integral lists: 223 definite integrals diffed against master, no changes.
  • New test: 10 cases. It fails 5 of 10 on master.
  • Full UnitTests suite: 21863 passed, 0 failed, 13 skipped (net10.0).
  • Build: 0 errors on every target framework.

Still left unevaluated, and not addressed here: the parametric integrals exp(-a x) sin(x) and exp(-a x) cos(2x) over [0, +oo), which need a > 0, and 1/(a + cos(x)) over [0, pi], which needs a > 1. Also unaddressed: 1/(a + sin(x)) over [0, 2 pi] times out.

Closes #2654.

🤖 Generated with Claude Code

…nts (#2654)

A definite integral of a piecewise or a provided expression is split at
the boundaries of its conditions. Only a comparison of the variable with
a number was read as a boundary. (x^3 - x)/(x^2 - 1) simplifies to
x provided not x^2 - 1 = 0, so its integral over [-2, 2] was left
unevaluated, although the condition fails only at -1 and 1 and the
integral is 0. A range with an infinite bound was not split at all. The
boundaries also went into the pieces as decimals, so a split at sqrt(2)
gave 3 - 1.41421... where the integral is 3 - sqrt(2).

An equation's solutions are now listed as boundaries, by the zero
lister the antiderivative breaks use, including periodic families such
as cos(x) = 0. A range with an infinite bound is split like a finite
one, taking its outer pieces' sample points one unit inside. Each
boundary is kept as written, so the pieces end at exact points. A
condition that fails on an interval still leaves no value there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.38462% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.71%. Comparing base (ad57ae3) to head (b69387f).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...ns/Continuous/Integration/BreakpointIntegration.cs 65.38% 3 Missing and 6 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2657      +/-   ##
==========================================
- Coverage   86.71%   86.71%   -0.01%     
==========================================
  Files         346      346              
  Lines       75660    75736      +76     
  Branches    22118    22149      +31     
==========================================
+ Hits        65608    65671      +63     
- Misses       5420     5423       +3     
- Partials     4632     4642      +10     
Flag Coverage Δ
cpp 37.77% <ø> (ø)
csharp 87.20% <65.38%> (-0.01%) ⬇️
fsharp 32.79% <ø> (ø)
interactive 40.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ns/Continuous/Integration/BreakpointIntegration.cs 69.29% <65.38%> (-0.61%) ⬇️

... and 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

A definite integral under a condition that fails at isolated points is left unevaluated: integral((x^3-x)/(x^2-1), x, -2, 2)

1 participant