Skip to main content

IntegrationInterval

Struct IntegrationInterval 

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

A finite interval for definite integration.

Implementations§

Source§

impl IntegrationInterval

Source

pub const fn new(start: f64, end: f64) -> Self

Creates an interval from start to end.

Source

pub fn try_new(start: f64, end: f64) -> Result<Self, CalculusError>

Creates an interval from finite bounds.

§Errors

Returns CalculusError::NonFiniteBound when start or end is not finite.

Examples found in repository?
examples/basic_usage.rs (line 5)
3fn main() -> Result<(), use_calculus::CalculusError> {
4    let differentiator = Differentiator::try_new(1.0e-5)?;
5    let interval = IntegrationInterval::try_new(0.0, 1.0)?;
6    let integrator = Integrator::try_new(128)?;
7    let limit = LimitApproximator::try_new(1.0e-6, 1.0e-5)?;
8
9    let slope = differentiator.derivative_at(|x| x.powi(2), 3.0)?;
10    let area = integrator.simpson(|x| x * x, interval)?;
11    let sinc_limit = limit.at(
12        |x| {
13            if x == 0.0 { 1.0 } else { x.sin() / x }
14        },
15        0.0,
16    )?;
17
18    assert!((slope - 6.0).abs() < 1.0e-6);
19    assert!((area - (1.0 / 3.0)).abs() < 1.0e-6);
20    assert!((sinc_limit - 1.0).abs() < 1.0e-5);
21
22    Ok(())
23}
Source

pub fn validate(self) -> Result<Self, CalculusError>

Validates that the stored bounds are finite.

§Errors

Returns the same error variants as Self::try_new.

Source

pub const fn start(&self) -> f64

Returns the start bound.

Source

pub const fn end(&self) -> f64

Returns the end bound.

Source

pub const fn width(&self) -> f64

Returns the signed interval width, end - start.

Trait Implementations§

Source§

impl Clone for IntegrationInterval

Source§

fn clone(&self) -> IntegrationInterval

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for IntegrationInterval

Source§

impl Debug for IntegrationInterval

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for IntegrationInterval

Source§

fn eq(&self, other: &IntegrationInterval) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IntegrationInterval

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.