Functions can be created using the f! macro, and you can evaluate them like any rust function with
the corresponding number of arguments, all of them f64’s.
As a bonus, you can also evaluate an n-sized Vector in an n-variable function, and it will work as intended.
They also save their expression as a string, which you can obtain as f.expression().
You can use the ddx!, ddy! and ddz! macros to take its derivative at a specific point, and use
the integral! macro to evaluate its integral.
For taking its limit you can use the limit! macro, which returns a number.
Finally, you can make a VectorFunction out of a two or three-dimensional function using
the grad! macro, which returns the gradient vector function.
Functions can also be cloned.
Note: You may get a syntax error for using a Function as a function, but it will compile correctly.
use vector_calculus::*;
let f:Function = f!(x, y, x*y); // Two variable function
let g:Function = f!(x, x.powi(2)); // Single variable function
assert_eq!(f(1., 2.), 2.);
assert_eq!(g(4.), 16.0);