Repository navigation
feat: add symbolic definite integration for piecewise functions - #413
Merged
Merged
Conversation
arnog
added a commit
that referenced
this pull request
Oct 6, 2026
…tions and enhance tests for exact results Contributed by [KingArth0r](https://github.com/KingArth0r
Member
|
Thanks, looks good, merged. While reviewing it we found that EvaluateAt turned irrational bounds into floats (∫₂^√5 4 dx gave 0.944…), which made many piecewise results inexact. That is fixed on main now, so ∫₀³ ⌊x²⌋ dx gives 21 − 3√2 − √3 − √5 − √6 − √7. |
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.
Summary
Add symbolic definite integration of piecewise expressions over finite real intervals. Partition the interval at established switch points, select each expression on the resulting open subintervals, and delegate the smooth pieces to the existing Integrate machinery.
Scope and safeguards
This is finite, real, symbolic definite integration, not a general inequality solver or an indefinite piecewise antiderivative implementation. Unsupported conditions, incomplete root sets, undecidable ordering/domain checks, and unresolved cell integrals remain unevaluated. Work is bounded by 128 interior cuts, 128 nonlinear solve calls, and a traversal budget. Infinite jump sets and general periodic/infinite-series reductions are not included. Nested combinations that cannot be classified completely may remain unevaluated.
Files
src/compute-engine/symbolic/piecewise-integrate.ts: partitioning, classification, and integration.src/compute-engine/library/calculus.ts: Integrate dispatch (plus one formatter-required line wrap).test/compute-engine/integrate-piecewise.test.ts: 60 regression tests.test/compute-engine/compile-integrate.test.ts: expect exact compilation for the newly solvable example; retain numerical-integration coverage with an unsupported nonlinear trig condition.Validation
Built on upstream main at 5130eec. Integral Benchmark changes are intentionally excluded.