10 releases
new 0.1.2 | Apr 30, 2024 |
---|---|
0.1.1 | Apr 19, 2024 |
0.0.61 | Apr 23, 2023 |
0.0.5 | Feb 19, 2023 |
#181 in Math
276 downloads per month
88KB
2.5K
SLoC
Functionalities
- Parsing from string to function
- support for 1/2/3 variable(s) functions
- supports the following functions:
- Ln, Sin, Cos, Tan, Sec, Csc, ASin, ACos, ATan, Sinh, Cosh, Tanh, Coth, Sech, Csch, ASinh, ACosh, ATanh, Abs
- Ability to define parameters
- Some kind of expression semplification
1D Functions
- Derivative
- Definite integral between a and b
- Evaluate functions at x
2D Functions
- Derivative
- Hessian
- Evaluate functions at (x,y)
3D Functions
- Derivative
- Hessian
- Evaluate functions at (x,y,z)
Examples
Create a function with a macro and calculate gradient and hessian
use ruut_functions::{f3d, F3D}
use std::str::FromStr;
let func_3d = f3d!("ysin(x)+ln(z)cos(x)");
let gradient = func_3d.derivative();
println!("{}", gradient);
// { ycos(x)-ln(z)sin(x) , sin(x) , cos(x)/z }
let hessian = func_3d.hessian();
println!("{}", hessian);
// | -ysin(x)-ln(z)cos(z) | cos(x) | -sin(x)/z |
// | cos(x) | 0 | 0 |
// | -sin(x)/z | 0 | -cos(x)/z^2 |
Create a function with a context and use the parameter
use ruut_functions::{ctx::Ctx, F3D};
let ctx = Ctx::new(vec![("eta", 0.69)]);
let func_3d = F3D::build("x*eta", &ctx);