{"id":32309186,"url":"https://github.com/fkleon/math-expressions","last_synced_at":"2026-02-21T08:36:54.715Z","repository":{"id":11010462,"uuid":"13336523","full_name":"fkleon/math-expressions","owner":"fkleon","description":"A library for parsing and evaluating mathematical expressions, supporting real numbers, vectors, and basic interval arithmetic.","archived":false,"fork":false,"pushed_at":"2026-01-12T10:40:07.000Z","size":3416,"stargazers_count":111,"open_issues_count":16,"forks_count":37,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-01-12T18:56:41.564Z","etag":null,"topics":["expression-evaluator","expression-parser","maths"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/math_expressions","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fkleon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2013-10-04T22:53:44.000Z","updated_at":"2026-01-12T10:40:09.000Z","dependencies_parsed_at":"2024-02-13T09:26:13.287Z","dependency_job_id":"db19c847-eefc-4601-afcc-515b29b64d0a","html_url":"https://github.com/fkleon/math-expressions","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/fkleon/math-expressions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkleon%2Fmath-expressions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkleon%2Fmath-expressions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkleon%2Fmath-expressions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkleon%2Fmath-expressions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fkleon","download_url":"https://codeload.github.com/fkleon/math-expressions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fkleon%2Fmath-expressions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29677620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T06:23:40.028Z","status":"ssl_error","status_checked_at":"2026-02-21T06:23:39.222Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["expression-evaluator","expression-parser","maths"],"created_at":"2025-10-23T08:16:09.204Z","updated_at":"2026-02-21T08:36:54.710Z","avatar_url":"https://github.com/fkleon.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# math_expressions\n\nA library for parsing and evaluating mathematical expressions.\n\n* Performs evaluations in real, vector, and [interval][bohlender2010] contexts.\n* Supports expression simplification and differentiation.\n\nmath_expressions is inspired by [mathExpr][] for Java and distributed under the\n[MIT license][LICENSE].\n\n## Features\n\n* Evaluation of expressions in various modes: Real, Vector and [Interval][bohlender2010].\n* Parsing, simplification and differentiation of mathematical expressions.\n* Supporting most [basic math functions][defaultFunctions] out of the box.\n* Extensible through custom function definitions in code.\n* Well [documented][dartdoc] and tested.\n\nThis package contains a very simple [command-line interpreter](bin/interpreter.dart)\nfor real numbers:\n\n    dart pub run math_expressions:interpreter\n\n### What's not working yet?\n\n* Some evaluations in vector and interval space (especially functions).\n* N-dimensional vectors. Curently no more than four dimensions are supported.\n* The parser only works for real numbers.\n* Complex numbers.\n\nSuggestions and pull requests are always welcome!\n\n## Usage\n\nBelow are two basic examples of how to use this library. There also is some [additional example code](example/main.dart) available.\n\n### 1. Expression creation and evaluation\n\nThis example shows how to evaluate\n\n$\\frac{(x^2+\\cos y)}{3}$\n\n\nfor $x=2, y=\\pi$\n\n#### Build the expression\n\nYou can either create an mathematical expression programmatically or parse a string.\n\n* Create the expression programmatically:\n```dart\n  var x = Variable('x'), y = Variable('y');\n  var xSquare = Power(x, 2);\n  var yCos = Cos(y);\n  var three = Number(3.0);\n  Expression exp = (xSquare + yCos) / three;\n```\n\n* Create the expression via the parser:\n```dart\n  ExpressionParser p = GrammarParser();\n  Expression exp = p.parse(\"(x^2 + cos(y)) / 3\");\n```\n\n#### Evaluate the expression\n\n* Bind variables and evaluate the expression as real number:\n```dart\n  // Bind variables:\n  var context = ContextModel()\n    ..bindVariableName('x', Number(2.0));\n    ..bindVariableName('y', Number(math.pi));\n\n  // Evaluate expression:\n  var evaluator = RealEvaluator(context);\n  num eval = evaluator.evaluate(exp);\n\n  print(eval) // = 1.0\n```\n\n### 2. Expression simplification and differentiation\n\nThis example shows how to simplify and differentiate\n\n$x \\cdot 1 - (-5)$\n\n* Expressions can be simplified and differentiated with respect to a given variable:\n```dart\n  Expression exp = p.parse(\"x*1 - (-5)\");\n\n  print(exp);            // = ((x * 1.0) - -(5.0))\n  print(exp.simplify()); // = (x + 5.0)\n\n  Expression expDerived = exp.derive('x');\n\n  print(expDerived);            // = (((x * 0.0) + (1.0 * 1.0)) - -(0.0))\n  print(expDerived.simplify()); // = 1.0\n```\n\n## Alternatives\n\nHere are some other Dart libraries that implement similar functionality to\nmath_expression: parsing and evaluating mathematical expressions.\n\n* [expressions][]: an elegant and small library to parse and evaluate simple\n  expressions.\n* [function_tree][]: a library for parsing, evaluating and plotting single- and\n  multi-variables numerical functions.\n\nTo the author's knowledge math_expressions is currently the only library\nsupporting interval arithmetics.\n\n[mathExpr]: https://www3.math.tu-berlin.de/geometrie/jtem/mathExpr/ \"The mathExpr library provides classes to parse and evaluate mathematical expressions.\"\n[bohlender2010]: https://interval.louisiana.edu/reliable-computing-journal/volume-15/no-1/reliable-computing-15-pp-36-42.pdf \"Deﬁnition of the Arithmetic Operations and Comparison Relations for an Interval Arithmetic Standard, PDF\"\n[license]: LICENSE \"MIT LICENSE\"\n[expressions]: https://pub.dartlang.org/packages/expressions \"A library to parse and evaluate simple expressions.\"\n[function_tree]: https://pub.dartlang.org/packages/function_tree \"A library for parsing and evaluating numerical functions built from strings.\"\n[dartdoc]: https://pub.dartlang.org/documentation/math_expressions/latest/\n[defaultFunctions]: https://pub.dartlang.org/documentation/math_expressions/latest/math_expressions/DefaultFunction-class.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkleon%2Fmath-expressions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffkleon%2Fmath-expressions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffkleon%2Fmath-expressions/lists"}