Skip to content

feat: adaptive Simpson's quadrature (integrate_adaptive) #31

Description

@bwyard

Context

integrate_simpson uses fixed subdivisions. For functions with localized variation (spikes, discontinuities), adaptive refinement is needed to match SciPy/GSL accuracy.

Proposed API

pub fn integrate_adaptive(f: fn(f32) -> f32, a: f32, b: f32, tol: f32, max_depth: u32) -> f32

Recursive adaptive Simpson's with Richardson extrapolation. Subdivides panels where |S_fine - S_coarse| > 15 * tol. O(h^4) per panel.

Thesis alignment

  • Pure: (f, a, b, tol, max_depth) -> f32
  • ADVANCE-EXCEPTION: recursion bounded by max_depth
  • No &mut in public API

Tests needed

  • sin(x) over [0, π] = 2.0 within 1e-6
  • More accurate than fixed Simpson at same evaluation count
  • Handles discontinuities (step function)
  • Deterministic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions