math_expressions
실수, 벡터 및 기본 구간 산술을 지원하는 수학식 파싱 및 평가를 위한 라이브러리입니다.
실수, 벡터 및 기본 구간 산술을 지원하는 수학식 파싱 및 평가를 위한 라이브러리입니다.
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A library for parsing and evaluating mathematical expressions.
math_expressions is inspired by mathExpr for Java and distributed under the MIT license.
This package contains a very simple command-line interpreter for real numbers:
dart pub run math_expressions:interpreter
Suggestions and pull requests are always welcome!
Below are two basic examples of how to use this library. There also is some additional example code available.
This example shows how to evaluate
$\frac{(x^2+\cos y)}{3}$
for $x=2, y=\pi$
You can either create an mathematical expression programmatically or parse a string.
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;
ExpressionParser p = GrammarParser();
Expression exp = p.parse("(x^2 + cos(y)) / 3");
// 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
This example shows how to simplify and differentiate
$x \cdot 1 - (-5)$
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
Here are some other Dart libraries that implement similar functionality to math_expression: parsing and evaluating mathematical expressions.
To the author's knowledge math_expressions is currently the only library supporting interval arithmetics.
의존성 목록 4 개
^7.0.0^2.1.3^6.0.0^1.25.7사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗