math_expressions
3.2.0, released 4 months ago by leonhardt.co.nz
Parse and evaluate mathematical expressions in real, vector, and interval contexts.
What it does
A library for parsing strings into mathematical expressions, evaluating them with context models, simplifying them, and computing derivatives. It supports real numbers, vectors, and basic interval arithmetic.
AI-written summary of version 3.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to evaluate mathematical formulas entered as strings at runtime.
- You need expression simplification or symbolic differentiation.
- You need interval arithmetic support.
Skip it when
- You need to parse complex numbers.
- You need to work with N-dimensional vectors where N is greater than four.
Strengths
- Supports real numbers, vectors, and interval arithmetic.
- Provides expression parsing, simplification, and differentiation.
- Extensible through custom function definitions in code.
Weaknesses
- Parser only works for real numbers out of the box.
- Does not support complex numbers.
- Some evaluations in vector and interval space (especially functions) are not working yet.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 2
ExpressionParser p = GrammarParser();
Expression exp = p.parse("(x^2 + cos(y)) / 3");
var context = ContextModel()
..bindVariableName('x', Number(2.0))
..bindVariableName('y', Number(math.pi));
var evaluator = RealEvaluator(context);
num eval = evaluator.evaluate(exp);Alternatives
Packages that do the same job and could replace math_expressions.
- fixed
Fixed decimal numbers with a fixed scale, stored as BigInts, supporting math, formatting and parsing.
79Compare - phone_numbers_parser
Dart library for parsing, validating, and formatting international phone numbers.
87Compare - advance_math
A Dart library for mathematical programming, complex numbers, algebra, statistics, and geometry.
66Compare - rsa_id_number
Validates, parses, and generates South African ID numbers.
55Compare
Works with
Packages commonly used together with math_expressions: ones it builds on, ones built on it, and its own family.
- petitparsermath_expressions depends on itBuild fast, composable, and type-safe grammars and parsers in plain Dart code.
- vector_mathmath_expressions depends on itVector math library for 2D/3D/4D vectors, matrices, quaternions, and geometry.
- fluent_uiBuilt on math_expressionsImplements Microsoft's Windows User Interface (Fluent UI) in Flutter.
- math_keyboardBuilt on math_expressionsMath expression editing with an on-screen software keyboard or physical keyboard input in Flutter.
- flutter_simple_calculatorBuilt on math_expressionsA Flutter widget that provides a simple calculator UI.