Skip to main content

AdaptiveTrapezoidIntegrationEngine

Struct AdaptiveTrapezoidIntegrationEngine 

Source
pub struct AdaptiveTrapezoidIntegrationEngine { /* private fields */ }
Expand description

Adaptive trapezoid quadrature: each interval is compared with its two halves and split again wherever they disagree, so samples concentrate where the integrand changes quickly.

An interval [a, b] with midpoint c is accepted when the one-panel and two-panel trapezoid values differ by less than its share of the tolerance; that difference is three times the error of the two-panel value, so the estimate is conservative. The tolerance is halved at each split, so the total error is bounded by roughly tolerance rather than by tolerance per interval. Intervals that reach 50 levels of subdivision (2⁻⁵⁰ of the original) are accepted as they are, which resolves jumps, where the difference shrinks only as fast as the tolerance; a non-finite sample is an error.

Implementations§

Source§

impl AdaptiveTrapezoidIntegrationEngine

Source

pub fn new(tolerance: f64, lower_bound: f64, upper_bound: f64) -> Self

An engine on [lower_bound, upper_bound] aiming for an absolute error below tolerance.

Source

pub fn set_tolerance(&mut self, x: f64)

Changes the error tolerance.

Trait Implementations§

Source§

impl CanIntegrate1D for AdaptiveTrapezoidIntegrationEngine

Source§

fn integrate<F>(&self, f: F) -> Result<f64, ErrorsJSL>
where F: Fn(f64) -> f64,

Approximates ∫ₐᵇ f(x) dx.
Source§

fn set_lower_bound(&mut self, x: f64)

Sets the lower bound a.
Source§

fn set_upper_bound(&mut self, x: f64)

Sets the upper bound b.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.