[−][src]Function reikna::integral::nth_integral
pub fn nth_integral(n: u64, f: &Function, c: f64, p: u64) -> Function
Return a Function
that estimates the n
th integral of f
, using a
constant of c
and a positive precision constant of p
.
The integration itself is done by integrate_wp()
, see the
documentation for integrate_wp()
for more information.
The precision value passed to integrate_wp()
is calculated with the
following formula:
precision = round(|x|) * p
Where p
is the precision constant supplied to this function.
Note -- the computational complexity of the resulting function grows
exponentially based on the value of n
, IE:
nth_integral(1, f, c, p)(x) -> O(1^x)
nth_integral(2, f, c, p)(x) -> O(2^x)
nth_integral(3, f, c, p)(x) -> O(3^x)
where x
is the value of x
supplied to the resulting function.
For this reason it is not recommended to use values of n
greater than
three or four, as larger values will cause computational complexity to
rapidly inflate.
Panics
Panics if p
equals zero.
Examples
#[macro_use] extern crate reikna; use reikna::integral::*; let f = func!(|x| x * x); let integral = nth_integral(1, &f, 1.0, DEFAULT_PRECISION); println!("integral({}) = {}", 0.0, integral( 0.0)); println!("integral({}) = {}", 1.0, integral( 1.0)); println!("integral({}) = {}", -2.0, integral(-2.0));
Outputs:
integral(0.0) = 1.0
integral(1.0) = 1.3333333333333333
integral(-2.0) = -1.6666666666666665