Skip to main content

symmetric_limit

Function symmetric_limit 

pub fn symmetric_limit<F>(
    function: F,
    at: f64,
    step: f64,
    tolerance: f64,
) -> Result<f64, CalculusError>
where F: FnMut(f64) -> f64,
Expand description

Approximates a two-sided limit with one symmetric sample scale.

§Errors

Returns CalculusError when step or tolerance is invalid, at is not finite, sampled evaluations are not finite, or the left and right samples disagree by more than tolerance.

§Examples

use use_calculus::symmetric_limit;

let limit = symmetric_limit(
    |x| {
        if x == 0.0 {
            1.0
        } else {
            x.sin() / x
        }
    },
    0.0,
    1.0e-6,
    1.0e-5,
)?;

assert!((limit - 1.0).abs() < 1.0e-5);