first_derivative

Function first_derivative 

Source
pub fn first_derivative<G, T: DualNum<F>, F: DualNumFloat, O: Mappable<Dual<T, F>>>(
    g: G,
    x: T,
) -> O::Output<(T, T)>
where G: Fn(Dual<T, F>) -> O,
Expand description

Calculate the first derivative of a scalar function.

let (f, df) = first_derivative(|x| x.powi(2), 5.0);
assert_eq!(f, 25.0);
assert_eq!(df, 10.0);