partial_d_dx

Function partial_d_dx 

Source
pub fn partial_d_dx<S>(expr: S, guess: &HashMap<S, Variable>, target: S) -> f64
where S: Copy + AsRef<str> + Display + Into<String> + Eq + Hash,
Expand description

Returns the partial derivative of a function w.r.t. the target variable.

ยงExample

use nexsys_math::partial_d_dx;
use nexsys_math::Variable;
use std::collections::HashMap;
let expr = "x^2 + y - z";
 
let X = HashMap::from([
    ("x", Variable::new(1_f64, None)),
    ("y", Variable::new(1_f64, None)),
    ("z", Variable::new(1_f64, None))
]);
 
let dFdx = partial_d_dx(expr, &X, "x");
assert_eq!(dFdx.round(), 2_f64);