Skip to main content

simpson_integrate

Function simpson_integrate 

Source
pub fn simpson_integrate<F>(f: F, a: f64, b: f64, n: usize) -> f64
where F: Fn(f64) -> f64,
Expand description

Numerical integration using Simpson’s rule.

§Arguments

  • f - The function to integrate
  • a - Lower bound of integration
  • b - Upper bound of integration
  • n - Number of subintervals (must be even)

§Returns

Approximate value of ∫_a^b f(x) dx

§Panics

Panics if n is not even