Skip to main content

simpson

Function simpson 

Source
pub fn simpson(y: &[f64], spacing: Spacing<'_>) -> Result<f64, ErrorsJSL>
Expand description

Simpson’s rule on pairs of intervals, (h₀ + h₁)/6 [(2 − h₁/h₀) y₀ + (h₀ + h₁)²/(h₀h₁) y₁ + (2 − h₀/h₁) y₂], the integral of the parabola through three samples (SciPy’s simpson). With an even number of samples, the last interval is integrated by the parabola through the last three samples (Cartwright’s correction), which keeps it exact for quadratics (but not cubics).