mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-02-28 22:31:15 +01:00
Improved accuracy for derivation
This commit is contained in:
parent
7a56322e0f
commit
ece50bf92c
@ -14,7 +14,7 @@ pub fn derive_func(
|
|||||||
const H: f64 = 0.000001;
|
const H: f64 = 0.000001;
|
||||||
let unit = &argument.unit.to_string();
|
let unit = &argument.unit.to_string();
|
||||||
let argument_with_h = Expr::Literal(argument.clone().add(context, H.into()).to_f64());
|
let argument_with_h = Expr::Literal(argument.clone().add(context, H.into()).to_f64());
|
||||||
let argument_without_h = Expr::Literal(argument.to_f64());
|
let argument_without_h = Expr::Literal(argument.sub(context, H.into()).to_f64());
|
||||||
|
|
||||||
let f_x_h = interpreter::eval_fn_call_expr(
|
let f_x_h = interpreter::eval_fn_call_expr(
|
||||||
context,
|
context,
|
||||||
@ -29,7 +29,7 @@ pub fn derive_func(
|
|||||||
unit,
|
unit,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(f_x_h.sub(context, f_x).div(context, H.into()))
|
Ok(f_x_h.sub(context, f_x).div(context, (2f64 * H).into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn integrate(
|
pub fn integrate(
|
||||||
|
Loading…
Reference in New Issue
Block a user