1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! # Calculus
//! This module contains functions related to calculus.
//! The functions include finding the value of a definite integral using the trapezoidal rule, finding the value of the derivative of a function at a point in Rust.
//! # Examples
//! ```
//! use rusty_math::calculus;
//! let result = calculus::integrate(&|x| x*x, 0.0, 3.0);
//! ```
/// Function to find the value of a definite integral using the trapezoidal rule
/// # Paramaters:
/// f: `&dyn Fn(f64) -> f64` - The function whose integral is to be found
/// a: `f64` - The lower limit of the integral
/// b: `f64` - The upper limit of the integral
/// # Returns:
/// `f64` - The value of the definite integral
/// # Examples
/// ```
/// use rusty_math::calculus::integrate;
/// let result = integrate(&|x| x*x, 0.0, 3.0);
/// ```
/// Function to find the value of the derivative of a function at a point
/// # Paramaters:
/// f: `&dyn Fn(f64) -> f64` - The function whose derivative is to be found
/// x: `f64` - The point at which the derivative is to be found
/// # Returns:
/// `f64` - The value of the derivative at the given point
/// # Examples
/// ```
/// use rusty_math::calculus::differentiate;
/// let result = differentiate(&|x| x*x, 3.0);
/// ```