Pakete, Repositories und App-Kategorien suchen

Paketdetailsv3.2.0

math_expressions

Eine Bibliothek zum Parsen und Auswerten mathematischer Ausdrücke mit Unterstützung für reelle Zahlen, Vektoren und grundlegende Intervallarithmetik.

AndroidiOSWebmacOSWindowsLinux
30-Tage-Downloads
101.000
Likes
382
Pub-Punkte
160

Paket installieren

flutter pub add math_expressions

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Ein Flutter/Dart-Paket zum Parsen und Auswerten mathematischer Ausdrücke mit Unterstützung für reelle Zahlen, Vektoren und grundlegende Intervallarithmetik. Es ermöglicht die dynamische Berechnung mathematischer Formeln aus Zeichenketten und ist daher ideal für Taschenrechner, wissenschaftliche Anwendungen und Datenanalysetools. Die Bibliothek ist leichtgewichtig, plattformübergreifend und lässt sich nahtlos in Flutter-Projekte integrieren. Sie unterstützt Standardoperatoren, Funktionen und benutzerdefinierte Variablen mit klarer Fehlerbehandlung bei ungültigen Eingaben. Perfekt für Entwickler, die eine flexible Auswertung mathematischer Ausdrücke benötigen, ohne einen Parser von Grund auf bauen zu müssen.

Anwendungsfälle

  • Wissenschaftliche Rechner
  • dynamische Formelbewertung
  • Datenanalyse in Apps
  • Bildungsmathematik-Werkzeuge
  • Physiksimulationen

Hauptmerkmale

  • Unterstützt reelle Zahlen und Vektoren
  • Grundlegende Intervallarithmetik
  • Benutzerdefinierte Variablen- und Funktionsdefinitionen
  • Plattformübergreifende Kompatibilität
  • Robuste Fehlerbehandlung
  • Zeichenkettenbasierte Ausdrucksparsing

Geeignet für

  • mathematisch anspruchsvolle Anwendungen
  • Bildungssoftware
  • Engineering- und Physik-Anwendungen
  • Rechner-Apps
  • datengesteuerte Benutzeroberflächen

Hinweise

  • Nicht für Hochleistungs-Zahlenberechnung optimiert
  • Beschränkt auf grundlegende Intervallarithmetik
  • Erfordert sorgfältige Eingabeverifizierung, um Injektionsähnliche Probleme zu verhindern
  • Keine integrierte Unterstützung für komplexe Zahlen

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

math_expressions

A library for parsing and evaluating mathematical expressions.

  • Performs evaluations in real, vector, and interval contexts.
  • Supports expression simplification and differentiation.

math_expressions is inspired by mathExpr for Java and distributed under the MIT license.

Features

  • Evaluation of expressions in various modes: Real, Vector and Interval.
  • Parsing, simplification and differentiation of mathematical expressions.
  • Supporting most basic math functions out of the box.
  • Extensible through custom function definitions in code.
  • Well documented and tested.

This package contains a very simple command-line interpreter for real numbers:

dart pub run math_expressions:interpreter
What's not working yet?
  • Some evaluations in vector and interval space (especially functions).
  • N-dimensional vectors. Curently no more than four dimensions are supported.
  • The parser only works for real numbers.
  • Complex numbers.

Suggestions and pull requests are always welcome!

Usage

Below are two basic examples of how to use this library. There also is some additional example code available.

1. Expression creation and evaluation

This example shows how to evaluate

$\frac{(x^2+\cos y)}{3}$

for $x=2, y=\pi$

Build the expression

You can either create an mathematical expression programmatically or parse a string.

  • Create the expression programmatically:
  var x = Variable('x'), y = Variable('y');
  var xSquare = Power(x, 2);
  var yCos = Cos(y);
  var three = Number(3.0);
  Expression exp = (xSquare + yCos) / three;
  • Create the expression via the parser:
  ExpressionParser p = GrammarParser();
  Expression exp = p.parse("(x^2 + cos(y)) / 3");
Evaluate the expression
  • Bind variables and evaluate the expression as real number:
  // Bind variables:
  var context = ContextModel()
    ..bindVariableName('x', Number(2.0));
    ..bindVariableName('y', Number(math.pi));

  // Evaluate expression:
  var evaluator = RealEvaluator(context);
  num eval = evaluator.evaluate(exp);

  print(eval) // = 1.0
2. Expression simplification and differentiation

This example shows how to simplify and differentiate

$x \cdot 1 - (-5)$

  • Expressions can be simplified and differentiated with respect to a given variable:
  Expression exp = p.parse("x*1 - (-5)");

  print(exp);            // = ((x * 1.0) - -(5.0))
  print(exp.simplify()); // = (x + 5.0)

  Expression expDerived = exp.derive('x');

  print(expDerived);            // = (((x * 0.0) + (1.0 * 1.0)) - -(0.0))
  print(expDerived.simplify()); // = 1.0

Alternatives

Here are some other Dart libraries that implement similar functionality to math_expression: parsing and evaluating mathematical expressions.

  • expressions: an elegant and small library to parse and evaluate simple expressions.
  • function_tree: a library for parsing, evaluating and plotting single- and multi-variables numerical functions.

To the author's knowledge math_expressions is currently the only library supporting interval arithmetics.

Kategorien

Abhängigkeiten

Abhängigkeiten 2 Einträge

Quell-Repository

Projekte, die dieses Paket verwenden

Ranglisten