pub struct IntegrationInterval { /* private fields */ }Expand description
A finite interval for definite integration.
Implementations§
Source§impl IntegrationInterval
impl IntegrationInterval
Sourcepub fn try_new(start: f64, end: f64) -> Result<Self, CalculusError>
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}Sourcepub fn validate(self) -> Result<Self, CalculusError>
pub fn validate(self) -> Result<Self, CalculusError>
Validates that the stored bounds are finite.
§Errors
Returns the same error variants as Self::try_new.
Trait Implementations§
Source§impl Clone for IntegrationInterval
impl Clone for IntegrationInterval
Source§fn clone(&self) -> IntegrationInterval
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IntegrationInterval
impl Debug for IntegrationInterval
Source§impl PartialEq for IntegrationInterval
impl PartialEq for IntegrationInterval
Source§fn eq(&self, other: &IntegrationInterval) -> bool
fn eq(&self, other: &IntegrationInterval) -> bool
Tests for
self and other values to be equal, and is used by ==.impl Copy for IntegrationInterval
impl StructuralPartialEq for IntegrationInterval
Auto Trait Implementations§
impl Freeze for IntegrationInterval
impl RefUnwindSafe for IntegrationInterval
impl Send for IntegrationInterval
impl Sync for IntegrationInterval
impl Unpin for IntegrationInterval
impl UnsafeUnpin for IntegrationInterval
impl UnwindSafe for IntegrationInterval
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more