org.mariuszgromada.math:MathParser.org-mXparser

mXparser is a super easy, rich, fast and highly flexible math expression parser library (parser and evaluator of mathematical expressions / formulas provided as plain text / string). Software delivers easy to use API for JAVA, Android and C# .NET/MONO (Common Language Specification compliant: F#, Visual Basic, C++/CLI). *** If you finnd the software useful donation is something you might consider: http://mathparser.org/donate/ *** Scalar Scientific Calculator, Charts and Scripts, Scalar Lite: https://play.google.com/store/apps/details?id=org.mathparser.scalar.lite *** Scalar Pro: https://play.google.com/store/apps/details?id=org.mathparser.scalar.pro *** ScalarMath.org: http://scalarmath.org/ *** MathSpace.pl: http://mathspace.pl/ ***


Keywords
android, binary-relations, bitwise-operators, boolean-expression, c-sharp, calculus, dotnet, dotnet-core, dotnet-standard, expression-evaluator, formula-parser, java, math-parser, mathematical-expressions-evaluator, mono, pcl, user-defined-structures, xamarin, xamarin-android, xamarin-ios
License
BSD-2-Clause

Documentation

mXparser icon

mXparser - a super easy, rich and highly flexible Mathematical Expression Parser (Math Parser, Expression Evaluator) library for JAVA, Android and C# .NET.

mXparser is a highly flexible parser of mathematical expressions provided as text. Software delivers easy to use API for JAVA and C# .NET.

Supported frameworks

  • JAVA: 1.5, 1.6, 1.7, 1.8
  • Android - tested with mxparser compiled using jdk 1.7
  • .NET / MONO: 2.0, 3.0, 3.5, 4.0, 4.5, 4.6 (CLS)

Main functionalities:

High flexibility functionalities

Project documentation

- mXparser - API (english)

- mXparser - WIKI (english)

- mXparser - Tutorial (english)

- MathSpace.pl - site about math with mXparser examples (polish)

- MathParser.org - site about mXparser (english)

mXparser in nutshell

[calculator] You want simple calculator...

Expression e = new Expression("2+3");
e.calculate();

:+1:

[parenthesis] A calculator supporting parenthesis...

Expression e = new Expression("2+(3-5)^2");
e.calculate();

:+1:

[predefined constants] You care about predefined constants...

Expression e = new Expression("2*pi");
e.calculate();

:+1:

[your own constants] You need to define your own constants...

Constant tau = new Constant("tau = 2*pi");
Expression e = new Expression("3*tau", tau);
e.calculate();

:+1:

[built-in functions] You enjoy using many built-in functions...

Expression e = new Expression("sin(2*pi)");
e.calculate();

:+1:

[not only unary functions] You do not limit yourself to unary functions...

Expression e = new Expression("gcd(2,5,10,30)");
e.calculate();

:+1:

[arguments] What about user defined arguments...

Argument x = new Argument("x = 5");
Expression e = new Expression("sin(x)");
e.calculate();

:+1:

[dependent arguments] You are considering dependent arguments...

Argument x = new Argument("x = 5");
Argument y = new Argument("y = 2*x", x);
Expression e = new Expression("sin(y)", y);
e.calculate();

:+1:

[logic] You need to apply some logic...

Argument x = new Argument("x = 5");
Expression e = new Expression("if(sin(x) > 5, 1, 0)", x);
e.calculate();

:+1:

[Boolean algebra] Yes, you are right, there is a support for Boolean algebra!

Expression e = new Expression("5=6");
e.calculate();

:+1:

[binary relations] And for binary relations as well!

Expression e = new Expression("5 <= 6");
e.calculate();

:+1:

mXparser i cool! But this is only the begging, we are just warming up!

[iterated operators] You want to play with iterated operators...

Expression e = new Expression("sum(i, 1, 10, 2*i^2 + pi)");
e.calculate();

:+1:

[iterated operators] You want to iterate differently by not necessarily whole numbes...

Expression e = new Expression("prod(i, 1, 5, i, 0.5)");
e.calculate();

:+1:

[iterated operators] You want to have more fun with math...

Argument x = new Argument("x = pi/2");
Expression e20 = new Expression("sum(n,0,10,(-1)^n*(x^(2*n+1))/(2*n+1)!)", x);
e.calculate();

:+1:

[calculus - differentiation] You still want more fun with calculus operations, i.e. differentiation...

Argument x = new Argument("x = pi/2");
Expression e = new Expression("cos(x)-der(sin(x), x)", x);
e.calculate();

:+1:

[calculus - integrals] And definite integrals as well...

Expression e = new Expression("2*int(sqrt(1-x^2), x, -1, 1)");
e.calculate();

:+1:

mXparser is even cooler! It is time to ask about ...

[user defined functions] user defined functions...

Function f = new Function("f(x,y) = sin(x) + cos(y)");
f.calculate(1,2);
Expression e = new Expression("f(1,2) - 10", f);
e.calculate();

:+1:

[user defined recursive function] Recursion is your desire...

Function f = new Function("f(n) = if( n>0, n*f(n-1), 1)");
f.calculate()

:+1:

[user defined recursive function] Any kind of recursion...

Function Cnk = new Function("Cnk(n,k) = if(k>0, if(k<n, Cnk(n-1,k-1)+Cnk(n-1,k), 1), 1)");
Cnk.calculate()

:+1:

If anything above matches you then mXparser is a good choce! mXparser is freely distributed under Simplified BSD licence, but still you can give credits to the author, and even donate if you wish :+1:

[grammar and syntax checking] mXparser can interact with end users as it supports syntax checking.

Expression e = new Expression("2+1/a");
e.checkSyntax();
mXparser.consolePrintln(e.getErrorMessage());

Enjoy :-)

Best regards, Mariusz Gromada