fn midpoint(rhs: fn(f64) -> f64, a: f64, b: f64, n: i32) -> f64 {
    // Width of one rectangle
    let h = (b - a) / n as f64;
    h * (0..n).fold(0.0, |acc, i| acc + rhs(a + h * i as f64 + h / 2.0))
}
/// Compute numerical integral of function of one real variable using the
/// composite midpoint rule
Compute numerical integral of function of one real variable using the
composite midpoint rule
Compute numerical integral of function of one real variable using the composite midpoint rule
fn midpoint(rhs: fn(f64) -> f64, a: f64, b: f64, n: i32) -> f64 {
    // Width of one rectangle
    let h = (b - a) / n as f64;
    h * (0..n).fold(0.0, |acc, i| acc + rhs(a + h * i as f64 + h / 2.0))
}
fn midpoint ( rhs : fn ( f64 ) -> f64 , a : f64 , b : f64 , n : i32 ) -> f64 { // Width of one rectangle let h = ( b - a ) / n as f64 ; h * ( 0 .. n ) . fold ( 0.0 , | acc , i | acc + rhs ( a + h * i as f64 + h / 2.0 ) ) }
Compute numerical integral of function of one real variable using the
composite midpoint rule
Compute numerical integral of function of one real variable using the composite midpoint rule
rhs
fn(f64) -> f64
a
f64
b
f64
n
i32
rhs
fn(f64) -> f64
a
f64
b
f64
n
i32