Unicode math | mXparser β Math Expressions Parser for JAVA, C#, C++, Kotlin, Android, .NET/MONO/Xamarin β Mathematical Formula Parser
TO SUPPORT MY WORK, ORDER A COMMERCIAL LICENSE
THANK YOU!
The tutorial consists of more than 200 live examples from 50 sections given separately for JAVA, C# and C++. Each of the examples can be copied and run on your own environment. In addition, mXparser provides an extensive collection of over 500 built-in math functions, expressions and symbols. Familiarize yourself with the scope and the syntax. Live testing is the best way to learn. Good luck! π
Tutorial Math Collection API spec Download
Below is the code for JAVA, C# (the code for C# is almost identical) and C++. To copy the code, double-click inside the frame.
Case 1: The square root β
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e = new Expression("β2");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e = new_Expression("β2");
mXparser::consolePrintln("Res: " + e->getExpressionString() + " = " + e->calculate());
Code result
[mXparser-v.5.2.1] Res: β2 = 1.4142135623730951
Case 2: The square root of the square root ββ
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e = new Expression("ββ16");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e = new_Expression("ββ16");
mXparser::consolePrintln("Res: " + e->getExpressionString() + " = " + e->calculate());
Code result
[mXparser-v.5.2.1] Res: ββ16 = 2.0
Case 3: The square root and parenthesis β()
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e = new Expression("ββ(8+8)");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e = new_Expression("ββ(8+8)");
mXparser::consolePrintln("Res: " + e->getExpressionString() + " = " + e->calculate());
Code result
[mXparser-v.5.2.1] Res: ββ(8+8) = 2.0
Case 4: The roots of various orders β β β
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e = new Expression("β16 + β27 + β16");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e = new_Expression("β16 + β27 + β16");
mXparser::consolePrintln("Res: " + e->getExpressionString() + " = " + e->calculate());
Code result
[mXparser-v.5.2.1] Res: β16 + β27 + β16 = 9.0
Case 5: SIGMA summation operator β
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Expression e = new Expression("β(i, 1, 5, i^2)");
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ExpressionPtr e = new_Expression("β(i, 1, 5, i^2)");
mXparser::consolePrintln("Res: " + e->getExpressionString() + " = " + e->calculate());
Code result
[mXparser-v.5.2.1] Res: β(i, 1, 5, i^2) = 55.0
Case 6: Unicode name of a user defined argument
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
Argument a = new Argument("Ξ± = 2Ο");
Argument b = new Argument("Ξ² = Ο/2");
Expression e = new Expression("sin(Ξ±) + cos(Ξ²)", a, b);
mXparser.consolePrintln("Res: " + e.getExpressionString() + " = " + e.calculate());
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
ArgumentPtr a = new_Argument("Ξ± = 2Ο");
ArgumentPtr b = new_Argument("Ξ² = Ο/2");
ExpressionPtr e = new_Expression("sin(Ξ±) + cos(Ξ²)", a, b);
mXparser::consolePrintln("Res: " + e->getExpressionString() + " = " + e->calculate());
Code result
[mXparser-v.5.2.1] Res: sin(Ξ±) + cos(Ξ²) = 0.0
Case 7: Show all Unicode built-in keywords
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
mXparser.consolePrintHelp("unicode");
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
mXparser::consolePrintHelp("unicode");
Code result
[mXparser-v.5.2.1] Help content limited to query: 'unicode' # Keyword Type Syntax Since Description - -------- ---- ------ ----- ----------- 1. Γ <Operator> a Γ b 5.0 Multiplication - Operator - Unicode math symbol 2. β¨ <Operator> a β¨ b 5.0 Multiplication - Operator - Unicode math symbol 3. β <Operator> a β b 5.0 Multiplication - Operator - Unicode math symbol 4. Γ· <Operator> a Γ· b 5.0 Division - Operator - Unicode math symbol 5. β <Operator> βx 5.0 Square root - Operator - Unicode math symbol 6. β <Operator> βx 5.0 Cube root - Operator - Unicode math symbol 7. β <Operator> βx 5.0 Fourth root - Operator - Unicode math symbol 8. β§ <Boolean operator> p β§ q 5.0 Logical conjunction AND - Boolean operator - Unicode math symbol 9. βΌ <Boolean operator> p βΌ q 5.0 Sheffer stroke NAND - Boolean operator - Unicode math symbol 10. ~β§ <Boolean operator> p ~β§ q 5.0 Sheffer stroke NAND - Boolean operator - Unicode math symbol 11. Β¬& <Boolean operator> p Β¬& q 5.0 Sheffer stroke NAND - Boolean operator - Unicode math symbol 12. Β¬β§ <Boolean operator> p Β¬β§ q 5.0 Sheffer stroke NAND - Boolean operator - Unicode math symbol 13. Β¬&& <Boolean operator> p Β¬&& q 5.0 Sheffer stroke NAND - Boolean operator - Unicode math symbol 14. Β¬/\ <Boolean operator> p Β¬/\ q 5.0 Sheffer stroke NAND - Boolean operator - Unicode math symbol 15. β¨ <Boolean operator> p β¨ q 5.0 Logical disjunction OR - Boolean operator - Unicode math symbol 16. β½ <Boolean operator> p β½ q 5.0 Logical not or (joint denial) NOR - Boolean operator - Unicode math symbol 17. ~β¨ <Boolean operator> p ~β¨ q 5.0 Logical not or (joint denial) NOR - Boolean operator - Unicode math symbol 18. Β¬| <Boolean operator> p Β¬| q 5.0 Logical not or (joint denial) NOR - Boolean operator - Unicode math symbol 19. Β¬β¨ <Boolean operator> p Β¬β¨ q 5.0 Logical not or (joint denial) NOR - Boolean operator - Unicode math symbol 20. Β¬|| <Boolean operator> p Β¬|| q 5.0 Logical not or (joint denial) NOR - Boolean operator - Unicode math symbol 21. Β¬\/ <Boolean operator> p Β¬\/ q 5.0 Logical not or (joint denial) NOR - Boolean operator - Unicode math symbol 22. β» <Boolean operator> p β» q 5.0 Exclusive or XOR - Boolean operator - Unicode math symbol 23. β <Boolean operator> p β q 5.0 Implication IMP - Boolean operator - Unicode math symbol 24. β <Boolean operator> p β q 5.0 Converse implication CIMP - Boolean operator - Unicode math symbol 25. β <Boolean operator> p β q 5.0 Material nonimplication NIMP - Boolean operator - Unicode math symbol 26. β <Boolean operator> p β q 5.0 Converse nonimplication CNIMP - Boolean operator - Unicode math symbol 27. β <Boolean operator> p β q 5.0 Logical biconditional EQV - Boolean operator - Unicode math symbol 28. Β¬ <Boolean operator> Β¬p 5.0 Negation - Boolean operator - Unicode math symbol 29. β <Binary relation> a β b 5.0 Inequation - Binary relation - Unicode math symbol 30. β€ <Binary relation> a β€ b 5.0 Lower or equal - Binary relation - Unicode math symbol 31. β <Binary relation> a β b 5.0 Lower or equal - Binary relation - Unicode math symbol 32. β₯ <Binary relation> a β₯ b 5.0 Greater or equal - Binary relation - Unicode math symbol 33. β <Binary relation> a β b 5.0 Greater or equal - Binary relation - Unicode math symbol 34. β <Calculus operator> β(i, from, to, expr, <by>) 5.0 Summation SIGMA - Iterated operator Ξ£ - Calculus operator - Unicode math symbol 35. Ξ£ <Calculus operator> Ξ£(i, from, to, expr, <by>) 5.0 Summation SIGMA - Iterated operator Ξ£ - Calculus operator - Unicode math symbol 36. β <Calculus operator> β(i, from, to, expr, <by>) 5.0 Product PI - Iterated operator β - Calculus operator - Unicode math symbol 37. βΏ <Calculus operator> βΏ(i, from, to, expr, <by>) 5.0 Product PI - Iterated operator β - Calculus operator - Unicode math symbol 38. Ξ <Calculus operator> Ξ (i, from, to, expr, <by>) 5.0 Product PI - Iterated operator β - Calculus operator - Unicode math symbol 39. β« <Calculus operator> β«(expr, arg, from, to) 5.0 Definite integral β« - Calculus operator - Unicode math symbol 40. β <Calculus operator> β(expr, arg, <point>) 5.0 Derivative β - Calculus operator - Unicode math symbol 41. β- <Calculus operator> β-(expr, arg, <point>) 5.0 Left derivative β- - Calculus operator - Unicode math symbol 42. β+ <Calculus operator> β+(expr, arg, <point>) 5.0 Right derivative β+ - Calculus operator - Unicode math symbol 43. β <Calculus operator> β(expr, arg, <delta>) 5.0 Forward difference β - Calculus operator - Unicode math symbol 44. Ξ <Calculus operator> Ξ(expr, arg, <delta>) 5.0 Forward difference β - Calculus operator - Unicode math symbol 45. β <Calculus operator> β(expr, arg, <delta>) 5.0 Backward difference β - Calculus operator - Unicode math symbol 46. Ο <Constant value> Ο 5.0 Pi, Archimedes' or Ludolph's number - Mathematical constant Ο - Constant value - Unicode math symbol 47. βΌ <Constant value> βΌ 5.0 Pi, Archimedes' or Ludolph's number - Mathematical constant Ο - Constant value - Unicode math symbol 48. β― <Constant value> β― 5.0 Napier's or Euler's number (base of Natural logarithm) - Mathematical constant e - Constant value - Unicode math symbol 49. β <Constant value> β 5.0 Napier's or Euler's number (base of Natural logarithm) - Mathematical constant e - Constant value - Unicode math symbol [mXparser-v.5.2.1]
Case 8: Enable / disable Unicode built-in keywords
Java/C# code
// JAVA: import org.mariuszgromada.math.mxparser.*;
// C#: using org.mariuszgromada.math.mxparser;
// ...
mXparser.disableUnicodeBuiltinKeyWordsMode();
mXparser.consolePrintHelp("unicode");
C++ code
#include "org/mariuszgromada/math/mxparser.hpp"
// ...
mXparser::disableUnicodeBuiltinKeyWordsMode();
mXparser::consolePrintHelp("unicode");
Code result
[mXparser-v.5.2.1] Help content limited to query: 'unicode' # Keyword Type Syntax Since Description - -------- ---- ------ ----- ----------- [mXparser-v.5.2.1]
List of Unicode symbols that grammar accepts
"Ξ±" = "\u03b1": can be used as var name "Ξ²" = "\u03b2": can be used as var name "Ξ³" = "\u03b3": can be used as var name "Ξ΄" = "\u03b4": can be used as var name "Ξ΅" = "\u03b5": can be used as var name "ΞΆ" = "\u03b6": can be used as var name "Ξ·" = "\u03b7": can be used as var name "ΞΈ" = "\u03b8": can be used as var name "ΞΉ" = "\u03b9": can be used as var name "ΞΊ" = "\u03ba": can be used as var name "Ξ»" = "\u03bb": can be used as var name "ΞΌ" = "\u03bc": can be used as var name "Ξ½" = "\u03bd": can be used as var name "ΞΎ" = "\u03be": can be used as var name "ΞΏ" = "\u03bf": can be used as var name "Ο" = "\u03c0": pi constant "Ο" = "\u03c1": can be used as var name "Ο" = "\u03c2": can be used as var name "Ο" = "\u03c3": can be used as var name "Ο" = "\u03c4": can be used as var name "Ο " = "\u03c5": can be used as var name "Ο" = "\u03c6": can be used as var name "Ο" = "\u03c7": can be used as var name "Ο" = "\u03c8": can be used as var name "Ο" = "\u03c9": can be used as var name "Ξ" = "\u0391": can be used as var name "Ξ" = "\u0392": can be used as var name "Ξ" = "\u0393": can be used as var name "Ξ" = "\u0394": Forward difference operator "Ξ" = "\u0395": can be used as var name "Ξ" = "\u0396": can be used as var name "Ξ" = "\u0397": can be used as var name "Ξ" = "\u0398": can be used as var name "Ξ" = "\u0399": can be used as var name "Ξ" = "\u039a": can be used as var name "Ξ" = "\u039b": can be used as var name "Ξ" = "\u039c": can be used as var name "Ξ" = "\u039d": can be used as var name "Ξ" = "\u039e": can be used as var name "Ξ" = "\u039f": can be used as var name "Ξ " = "\u03a0": Product operator - PI "Ξ‘" = "\u03a1": can be used as var name "Ξ£" = "\u03a3": Summation operator - SIGMA "Ξ€" = "\u03a4": can be used as var name "Ξ₯" = "\u03a5": can be used as var name "Ξ¦" = "\u03a6": can be used as var name "Ξ§" = "\u03a7": can be used as var name "Ξ¨" = "\u03a8": can be used as var name "Ξ©" = "\u03a9": can be used as var name "β" = "\u2211": Summation operator - SIGMA "β" = "\u220f": Product operator - PI "βΏ" = "\u213f": Product operator - PI "β" = "\u2206": Forward difference operator "β" = "\u2207": Backward difference operator "β«" = "\u222b": Definite integral operator "βΌ" = "\u213c": pi constant "β" = "\u2107": can be used as var name "β " = "\u2147": Napier's constant, or Euler's number, base of Natural logarithm "β―" = "\u212f": Napier's constant, or Euler's number, base of Natural logarithm "β" = "\u221c": Fourth root function represented as unary left operator "β" = "\u221b": Cube root function represented as unary left operator "β" = "\u221a": Square root function represented as unary left operator "β" = "\u2202": Derivative operator "β»" = "\u22bb": Exclusive or (XOR) "β½" = "\u22bd": Logical NOR "βΌ" = "\u22bc": NAND - Sheffer stroke "β" = "\u21d4": Logical biconditional (EQV) "β" = "\u21cd": Converse nonimplication (CNIMP) "β" = "\u21cf": Material nonimplication (NIMP) "β" = "\u21d0": Converse implication (CIMP) "β" = "\u21d2": Implication (IMP) "Β¬" = "\u00ac": Negation "β§" = "\u2227": And "β¨" = "\u2228": Or "β" = "\u22dd": Greater or equal "β₯" = "\u2265": Greater or equal "β" = "\u22dc": Lower or equal "β€" = "\u2264": Lower or equal "β " = "\u2260": Inequation "Γ·" = "\u00f7": Division "β" = "\u2219": Multiplication "β¨" = "\u2a09": Multiplication "Γ" = "\u00d7": Multiplication
Nuget β Package Manager (C#, F#, Visual Basic, β¦)
Install-Package MathParser.org-mXparser -Version 6.1.0
dotnet add package MathParser.org-mXparser --version 6.1.0
<PackageReference Include="MathParser.org-mXparser" Version="6.1.0"/>
Maven β Dependency (Java, Kotlin, Scala, Groovy, β¦)
<dependency>
<groupid>org.mariuszgromada.math</groupid>
<artifactid>MathParser.org-mXparser</artifactid>
<version>6.1.0</version>
</dependency>
Maven β Gradle
implementation 'org.mariuszgromada.math:MathParser.org-mXparser:6.1.0'
CMake β Dependency / FetchContent (C++, MSVC, LLVM/Clang, GNU/GCC, MinGW, MSYS2, WSL, Windows, Linux, Unix, MacOS)
include(FetchContent)
FetchContent_Declare(
MathParserOrgMxParser
GIT_REPOSITORY https://github.com/mariuszgromada/MathParser.org-mXparser.git
GIT_TAG v.6.1.0
SOURCE_SUBDIR CURRENT/cpp/lib
)
FetchContent_MakeAvailable(MathParserOrgMxParser)
target_link_libraries(YourExecutable MathParserOrgMxParser)
GitHub
git clone https://github.com/mariuszgromada/MathParser.org-mXparser
OTHER DOWNLOAD OPTIONS
Download latest release β v.6.1.0 Sagitara: .NET bin onlyDownload latest release β v.6.1.0 Sagitara: JAVA bin onlyDownload latest release β v.6.1.0 Sagitara: bin + doc
NEWS FROM MATHPARSER.ORG
SOURCE CODE
Source code .zipSource code .tar.gz
View on GitHubMathSpace.pl
