Skip to content

[Repo Assist] feat: add integrate to LinearSpline, Step, and CubicSpline#375

Draft
github-actions[bot] wants to merge 2 commits intodeveloperfrom
repo-assist/improve-interpolation-integrate-20260413-a4be8a75855ed951
Draft

[Repo Assist] feat: add integrate to LinearSpline, Step, and CubicSpline#375
github-actions[bot] wants to merge 2 commits intodeveloperfrom
repo-assist/improve-interpolation-integrate-20260413-a4be8a75855ed951

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 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

Module Function Formula
Interpolation.LinearSpline integrate lsc x1 x2 Closed-form: C0·(x2-x1) + C1·((x2-xk)2-(x1-xk)2)/2 per segment
Interpolation.Step integrate lsc x1 x2 C0·(x2-x1) per segment
Interpolation.CubicSpline integrate coef x1 x2 Closed-form antiderivative: a·x4/4 + b·x3/3 + c·x2/2 + d·x per segment

All three accumulate partial integrals across segment boundaries for arbitrary [x1, x2] spans.

Remaining from #291

  • Akima.integrate — already exists
  • Polynomial.integrate — already exists
  • Step, LinearSpline, CubicSpline — this PR
  • Hermite — more complex (basis function expansion needed)
  • Regression integrations (linear, polynomial, smoothing spline) — future work

Test Status

5 new tests added; all cover known analytical results:

  • y = 2x: ∫[0,4] = 16, ∫[1,3] = 8
  • Step function: ∫[0,3] = 9, ∫[0.5,2.5] = 6
  • y = x2 (Quadratic BC): ∫[1,4] = 21, ∫[1,2] = 7/3
  • Equal-bound returns 0

1198/1198 tests pass on Linux.

Closes part of #291.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@97143ac59cb3a13ef2a77581f929f06719c7402a

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants