[Repo Assist] feat: add integrate to LinearSpline, Step, and CubicSpline#375
Draft
github-actions[bot] wants to merge 2 commits intodeveloperfrom
Draft
Conversation
Implements definite integral computation for three piecewise interpolation types, addressing part of issue #291. - LinearSpline.integrate: exact integral of piecewise linear function - Step.integrate: exact integral of step function - CubicSpline.integrate: exact integral of piecewise cubic polynomial All three use closed-form antiderivatives for numerical precision. Adds 5 new tests covering known analytical results (y=2x, y=x^2, step). 1198/1198 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds exact definite integral functions to three piecewise interpolation types, partially addressing #291.
New functions
Interpolation.LinearSplineintegrate lsc x1 x2C0·(x2-x1) + C1·((x2-xk)2-(x1-xk)2)/2per segmentInterpolation.Stepintegrate lsc x1 x2C0·(x2-x1)per segmentInterpolation.CubicSplineintegrate coef x1 x2a·x4/4 + b·x3/3 + c·x2/2 + d·xper segmentAll three accumulate partial integrals across segment boundaries for arbitrary
[x1, x2]spans.Remaining from #291
Akima.integrate— already existsPolynomial.integrate— already existsTest Status
5 new tests added; all cover known analytical results:
y = 2x:∫[0,4] = 16,∫[1,3] = 8∫[0,3] = 9,∫[0.5,2.5] = 6y = x2(Quadratic BC):∫[1,4] = 21,∫[1,2] = 7/31198/1198 tests pass on Linux.
Closes part of #291.