math_expressions
A library for parsing and evaluating mathematical expressions, supporting real numbers, vectors, and basic interval arithmetic.
3.2.0
104K downloads/mo
#1106 most downloaded on pub.dev
fkleon/math-expressions
What this package is like to depend on
Last release 26 days ago
29 Jul 2026
Ships fairly regularly
a new release about every 5 months
Nearly every release is documented
notes for 33 of 33 stable releases
Nothing withdrawn
no release was ever pulled
13 years old
37 releases · first in 2013
1 release in the last 12 months
see the full history below
Release timeline
37 releases · Oct 2013 to Jul 2026Releases
latest 37-
3.2.029 Jul 2026Release notes
Open source →Added
- Add support for implicit multiplication to
GrammarParser. - Add
useTraditionalMathDefinitionsoption toRealEvaluatorto returndouble.nanfor mathematically undefined operations (e.g. division by zero,0^0,tan(pi/2)) instead of following Dart's default floating-point behavior.
- Add support for implicit multiplication to
-
3.1.029 Jun 2025 -
3.0.013 Jun 2025Release notes
Open source →Added
-
Add support for listing all variables in an
Expressionwith theVariableCollectorvisitor. #73 -
Add support for evaluating an
Expressionwith the visitor interface:RealEvaluator(as real number),IntervalEvaluator(as interval),VectorEvalutor(as vector). This offers a strongly typed interface and replacesExpression.evaluate():// Old dynamic result = expression.evaluate(EvaluationType.REAL, context); // New var evaluator = RealEvaluator(context); int result = evaluator.evaluate(expression);
Changed
- The
Rootfunction now accepts anExpressionas degree. - Handler functions passed to
AlgorithmicFunctioncan no longer be dynamically typed.
Deprecated
- The
Expression.evaluate()method. UseRealEvaluatorinstead.
-
-
2.7.005 Feb 2025Release notes
Open source →Added
- Rewrite of the expression parser, available as
GrammarParser.- Add support for constants:
e,pi,ln10,ln2,log10e,log2e,sqrt1_2andsqrt2. - Custom constant symbols are supported via
ParserOptions. - Identifier naming is more restrictive. Names must start with a letter or
$, followed by any number of word characters (letter or digit). - This library now depends on
petitparser.
- Add support for constants:
Deprecated
- The old expression parser is now deprecated. It is still exposed under the
type alias
Parserto maintain backwards compatibility.
Fixed
- Exception when define variable Number with character "e" #82
- Suppress conversion into e function #61
- Variables should resolve before keywords. #31
- Rewrite of the expression parser, available as
-
2.7.0-rc.303 Feb 2025 pre-releaseRelease notes
Open source →Added
- Add support for additional constants to
GrammarParser:ln10,ln2,log10e,log2e,sqrt1_2andsqrt2. - Add ability to specify custom constants through
ParserOptions: This enables parsing of constant symbols that do not match the allowed variable identifier naming schema.
- Add support for additional constants to
-
2.7.0-rc.202 Feb 2025 pre-releaseRelease notes
Open source →Added
- Add support for n-th root function to
GrammarParser.
Fixed
- Tighten dependency constraints to fix issue with lower bounds dependencies.
- Add support for n-th root function to
-
2.7.0-rc.101 Feb 2025 pre-releaseRelease notes
Open source →Added
- Add a modern grammar-based expression parser. This is opt-in at this stage,
and can be used by instantiating a
GrammarParserinstead of the legacyParser. The new parser fixes some long-standing issues with expression parsing, but is still missing a few features that were previously supported by the legacy parser:- Implicit multiplication is not supported yet.
- Parsing of the n-th root function is not supported yet.
- Identifier naming is more restrictive, names must start with a letter or
$, followed by any number of word characters (letter or digit). This is mostly relevant for user-provided identifiers (algorithmic functions and variables).
- Add support for parsing constants, with initial support for
piande(Euler's constant). #26
Deprecated
- Renamed the existing expression parser to
ShuntingYardParser. This parser is now in maintenance mode and will not receive any new features.Parserremains as a deprecated type alias to this legacy implementation to maintain backwards compatibility.
Fixed
- Exception when define variable Number with character "e" #82
- Suppress conversion into e function #61
- Variables should resolve before keywords. #31
- Add a modern grammar-based expression parser. This is opt-in at this stage,
and can be used by instantiating a
-
2.6.031 Jul 2024Release notes
Open source →Added
- Add parser support for implicit multiplication (thanks juca1331)
Changed
- Drop support for Dart SDK versions below 3.1.0
-
2.5.015 Apr 2024Release notes
Open source →Added
- Add support for parsing variables containing digits (thanks alexander-zubkov)
Changed
- Drop support for Dart SDK versions below 3.0.0
- Refactor unit test suites and improve test coverage
- Switch from pedantic to the official Dart lint rules
-
2.4.005 Apr 2023 -
2.3.130 May 2022Release notes
Open source →Changed
- Evaluate roots written as powers correctly for negative bases (thanks edhom)
-
2.3.020 Dec 2021Release notes
Open source →Added
- Add factorial function (thanks Just-Learned-It)
Changed
- Switch from Travis CI to GitHub Actions
- Adopt Keep a Changelog format
-
2.2.004 Aug 2021Release notes
Open source →- Add algorithmic function that is bound to a Dart handler function, including parser support (thanks kamimark)
-
2.1.102 May 2021Release notes
Open source →- Fix inaccuracies in sin/cos/tan when using math.pi (machine pi) (thanks mbullington)
-
2.1.016 Mar 2021 -
2.1.0-nullsafety.012 Mar 2021 pre-releaseRelease notes
Open source →- Drop support for Dart SDK versions below 2.12.0
- Migrate to null safety (thanks albertodev01)
-
2.0.208 Jan 2021Release notes
Open source →- Lower precedence of unary minus below power operator to match common
mathematics conventions so that
-x^yis parsed as-(x^y)instead of(-x)^y
- Lower precedence of unary minus below power operator to match common
mathematics conventions so that
-
2.0.107 Sep 2020Release notes
Open source →- Add ability to unbind variable names (by wdavies973)
- Fix parsing of
ceilfunction (by pepsin)
-
2.0.008 Mar 2020Release notes
Open source →- Drop support for Dart SDK versions below 2.1.1
- Enable
unnecessary_newlint rule - Parser throws
FormatExceptioninstead ofStateErrororArgumentErrorfor invalid input string - Remove underscore syntax previously supported for unary minus
- Fix toString() parser compatibility for the following expressions:
- Logarithm function: Change string representation from
log_b(x)tolog(b, x) - N-th root function: Change string representation from
nrt_n(x)tonrt(n, x) - Exponential function: Change string representation from
exp(x)toe(x)
- Logarithm function: Change string representation from
-
1.1.116 Apr 2019 -
1.1.016 Apr 2019Release notes
Open source →- Drop support for Dart SDK versions below 2.0.0
- Add arcsin, arccos, arctan functions
- Fix floor and ceil functions
- Update examples and documentation
- Switch to pedantic analysis options
-
1.0.010 Aug 2018Release notes
Open source →- Add support for Dart 2.0
- Drop support for Dart SDK versions below 1.24.0
- Depend on
vector_math2.0.0 or newer
-
0.4.010 Aug 2018Release notes
Open source →- Last release to only support Dart 1.x
- Prepare for Dart 2.0
- Enable strong mode
- Analyzer and linter fixes
- Drop support for Dart SDK versions below 1.21.0
-
0.3.009 Jul 2016Release notes
Open source →- Rename
Point3DtoPoint3 Point3now is a subtype ofVector3- Add mod (%) operator and ceil, floor functions
- Fixing a few missed chain rules in
derive
- Rename
-
0.2.019 Nov 2015Release notes
Open source →- Add support for basic vector operations
- Switch to using
testinstead ofunittestpackage - Warning: Depends on git version of
vector_mathas latest pub release is severely outdated
-
0.2.0+130 Dec 2015 -
0.1.019 Jul 2014Release notes
Open source →- Add absolute value function (by markhats)
- Add sign function
- Improve test coverage
- Adapt string representation of unary minus to standard syntax
-
0.0.930 Mar 2014Release notes
Open source →- To create exponentials, use
e(x)ore^x. Consequently, removed support forexp(x). - Improve test coverage
- Update dependencies
- To create exponentials, use
-
0.0.810 Dec 2013 -
0.0.709 Nov 2013Release notes
Open source →- Introduce nested context/naming scopes
- Improve vector evaluation
- Add some missing methods
- Improve test coverage (custom and composite functions)
- Remove boilerplate code
-
0.0.607 Nov 2013Release notes
Open source →- Add compose operator for functions:
Use
&to conveniently create a CompositeFunction from two existing functions:expr = f & g; - Improve documentation and dartdoc generation
- Add compose operator for functions:
Use
-
0.0.507 Nov 2013 -
0.0.411 Oct 2013Release notes
Open source →- Fix handling of operator associativity
- Add support for default functions to parser
- Add support for unary minus to parser:
Input with underscore. Instead of
2*-5use2*_5.
-
0.0.309 Oct 2013Release notes
Open source →- Add cli evaluator to examples
- Improve test coverage
- Fix bug in differentiation of Sin and Cos
- Remove support of unary minus in Parser
-
0.0.207 Oct 2013Release notes
Open source →- Improve test coverage
- Improve documentation
- Fix bug in simplification of Minus
- Fix bug in simplification of Times
- Implement evaluation of nth root
-
0.0.104 Oct 2013 -
0.0.1+106 Oct 2013