ruut-functions 0.1.2

A math library that allows for parsing functions from string and perform integration, derivation and evaluation. Also supports functions with 2 and 3 variables
Documentation

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);