[−][src]Function reikna::integral::integrate_wp
pub fn integrate_wp(f: &Function, a: f64, b: f64, p: u64) -> f64
Estimate the value of the integral of f
over [a, b]
using
p
subintervals.
This function works by applying Simpson's rule to the function
over the specified interval, using p
subintervals.
Note that a higher p
will increase the accuracy of the result,
but also increase the time the computation takes. p
should be chosen
to ensure that a good estimate can be made without drastically
increasing the computational complexity.
If a
is equal to b
or p
equals zero, zero
will be
returned.
Examples
#[macro_use] extern crate reikna; use reikna::integral::*; let f = func!(|x| x + 4.0); assert_eq!(integrate_wp(&f, 0.0, 0.0, 10), 0.0); assert_eq!(integrate_wp(&f, 0.0, 1.0, 10), 4.5);