This repo/crate provides a number of math utilities:
- Parsing and evaluating expressions containing a combination of matrices, vectors and scalars.
- Solving equations and system of equations (both linear and non-linear).
- Exporting a LaTeX document from a collection of parsed and evaluated expressions.
:warning: This repo/crate has not hit 1.0.0 yet, breaking changes are bound to happen!
Major features
- Parsing and evaluating calculations with matrices, vectors and scalars.
- A recursive parsing implementation allowing for calculations withing matrices and vectors.
- An inbuilt equation solver for solving linear and non-linear systems of equations, accessible through a custom "function".
- An evaluator based on combinatorics for combining multiple results from equations or sqrt with other operations.
- Inbuilt quality of life functions for exporting results to latex.
Crate features
- high-prec: uses a precision of 13 instead of 8 (will slow down execution).
- row-major: parses matrices in a row major format.
- output: enables dependencies in order to provide rendered PDFs, PNGs and SVGs. (currently broken)
- serde: enables serde::Serialize and serde::Deserialize on most structs and enums.
Usage
For usage information concerning the mathematical properties of the evaluator and more examples, please take a look at the wiki.
For programming documentation, please take a look at docs.rs.
Examples
let res = quick_eval?.to_vec;
assert_eq!;
let x = new;
let res = quick_eval?.to_vec;
assert_eq!;
let res = quick_eval?.to_vec;
assert_eq!;
let function = parse?;
let function_var = new;
let res = quick_eval?.to_vec;
assert_eq!;
let res = quick_eval?.round.to_vec;
assert_eq!;
let equation = "eq(2x+5y+2z=-38, 3x-2y+4z=17, -6x+y-7z=-12, x, y, z)";
let res = quick_eval?.round.to_vec;
assert_eq!;
[!CAUTION] Due to dependency issues output is currently broken!
let parsed_expr = parse?;
let res = eval?;
let step = Calc ;
let png = png_from_latex?;
Output:
TODO
- Support for vectors and matrices
- Calculations in vectors and matrices
- Equations as operators -> eval can handle multiple values
- Complex numbers
- Possible tensor support
- Stable API that makes everyone happy (very hard)
Issues and Contributions
When opening an issue, please specify the following:
- The mathematical expression that causes the issue
- The error (or lack of it), be it a MathLibError or any other kind of error
- The expected behavior
When it comes to contributions, feel free to fork this repo and open pull requests.