Function math_utils_lib::quick_solve
source · pub fn quick_solve(
expr: String,
solve_var: String,
vars: Vec<Variable>
) -> Result<Vec<Value>, QuickSolveError>Expand description
solves a given equation towards a given Variable Name (solve_var). It can additionaly be provided with other variables. If you just want a root finder, have a look at find_roots().
§Example
let equation = "x^2=9".to_string();
let res = quick_solve(equation, "x".to_string(), vec![])?;
let res_rounded = res.iter().map(|x| Value::Scalar((x.get_scalar()*1000.).round()/1000.)).collect::<Vec<Value>>();
assert_eq!(res_rounded, vec![Value::Scalar(3.), Value::Scalar(-3.)]);