#expression-parser #expression #parser #evaluator

pemel

Parsing and Evaluating of Math Expressions Library

2 unstable releases

new 0.2.0 Feb 11, 2025
0.1.0 Jan 22, 2025

#337 in Math

Download history 104/week @ 2025-01-19 12/week @ 2025-01-26 5/week @ 2025-02-02

121 downloads per month

MIT license

33KB
742 lines

PEMEL

Crates.io License

Overview

pemel is a Rust library providing a utilities for parsing and evaluating mathematical expressions.

Features

  • Basic arithmetic operations
  • Trigonometric functions
  • Exponential and logarithmic functions
  • Absolute value function
  • Evaluation with multiple variables
  • Numeric derivatives
  • Implicit evaluation during parsing

Usage

Here is a simple example of how to use pemel:

use pemel::prelude::*;

fn main() {
    let input = "2 * x^2 - 5 * log(x)";
    let expr = Expr::parse(input).unwrap();
    let result = expr.eval_with_variable("x", 10.0).unwrap();

    println!("{}", result); // Output: 195.0
}

Contributing

Untill I create a CONTRIBUTING.md file, I will not accept any pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

No runtime deps