Mxparser

Last updated
MathParser.org-mXparser
Original author(s) Mariusz Gromada
Initial releaseJanuary 2010;14 years ago (2010-01)
Stable release
6.0.0 / 19 May 2024;11 days ago (2024-05-19)
Repository github.com/mariuszgromada/MathParser.org-mXparser/
Written in Java, C#
Platform JVM, Android, .NET, .NET Core, .NET Standard, Windows Phone, MONO, Xamarin, Xamarin.iOS, Xamarin.Android
Website mathparser.org

mXparser is an open-source mathematical expressions parser/evaluator providing abilities to calculate various expressions at a run time. [1] Expressions definitions are given as plain text, then verified in terms of grammar / syntax, finally calculated. Library source code is maintained separately for Java and C#, providing the same API for Java/JVM, Android, .NET and Mono (Common Language Specification Compliant).

Contents

Main features / usage examples

mXparser delivers functionalities such as: basic calculations, implied multiplication, built-in constants and functions, numerical calculus operations, iterated operators, user defined constants, user defined functions, user defined recursion, Unicode mathematical symbols support.

Basic operators [2]

mXparser supports basic operators, such as: addition '+', subtraction '-', multiplication '*', division '/', factorial '!', power '^', modulo '#'.

Expressione=newExpression("2+3/(4+5)^4");doublev=e.calculate();

Implied multiplication [2]

Expressione=newExpression("2(3+4)3");doublev=e.calculate();
Expressione=newExpression("2pi(3+4)2sin(3)e");doublev=e.calculate();

Binary relations [2]

It is possible to combine typical expressions with binary relations (such as: greater than '>', less than '<', equality '=', inequality '<>', greater or equal '>=', lower or equal '<='), as each relation evaluation results in either '1' for true outcome, or '0' for false.

Expressione=newExpression("(2<3)+5");doublev=e.calculate();

Boolean logic [2]

Boolean logic also operates assuming equivalence of '1 as true' and '0 as false'. Supported Boolean operators include: AND conjunction, OR disjunction, NAND Sheffer stroke, NOR, XOR Exclusive OR, IMP Implication, CIMP Converse implication, NIMP Material nonimplication, CNIMP Converse nonimplication, EQV Logical biconditional, Negation.

Expressione=newExpression("1 --> 0");doublev=e.calculate();

Built-in mathematical functions [2]

Supported common mathematical functions (unary, binary and variable number of arguments), including: trigonometric functions, inverse trigonometric functions, logarithm functions, exponential function, hyperbolic functions, Inverse hyperbolic functions, Bell numbers, Lucas numbers, Stirling numbers, prime-counting function, exponential integral function, logarithmic integral function, offset logarithmic integral, binomial coefficient and others.

Expressione=newExpression("sin(0)+ln(2)+log(3,9)");doublev=e.calculate();
Expressione=newExpression("min(1,2,3,4)+gcd(1000,100,10)");doublev=e.calculate();
Expressione=newExpression("if(2<1, 3, 4)");doublev=e.calculate();
Expressione=newExpression("iff(2<1, 1; 3<4, 2; 10<2, 3; 5<10, 4)");doublev=e.calculate();

Built-in math constants [2]

Built-in mathematical constants, with high precision.

Expressione=newExpression("sin(pi)+ln(e)");doublev=e.calculate();

Iterated operators [2]

Iterated summation and product operators.

Expressione=newExpression("sum(i, 1, 10, ln(i))");doublev=e.calculate();
Expressione=newExpression("prod(i, 1, 10, sin(i))");doublev=e.calculate();

Numerical differentiation and integration [2]

mXparser delivers implementation of the following calculus operations: differentiation and integration.

Expressione=newExpression("der( sin(x), x )");doublev=e.calculate();
Expressione=newExpression("int( sqrt(1-x^2), x, -1, 1)");doublev=e.calculate();

Prime numbers support [2]

Expressione=newExpression("ispr(21)");doublev=e.calculate();
Expressione=newExpression("Pi(1000)");doublev=e.calculate();

Unicode mathematical symbols support [2]

Expressione=newExpression("√2");doublev=e.calculate();
Expressione=newExpression("∜16 + ∛27 + √16");doublev=e.calculate();
Expressione=newExpression("∑(i, 1, 5, i^2)");doublev=e.calculate();

Elements defined by user

Library provides API for creation of user-defined objects, such as: constants, arguments, functions.

User-defined constants [3]

Constantt=newConstant("t = 2*pi");Expressione=newExpression("sin(t)",t);doublev=e.calculate();

User-defined arguments [3]

Argumentx=newArgument("x = 5");Argumenty=newArgument("y = 2*x",x);Expressione=newExpression("sin(x)+y",x,y);doublev=e.calculate();

User-defined functions [3]

Functionf=newFunction("f(x, y) = sin(x)+cos(y)");Expressione=newExpression("f(1,2)",f);doublev=e.calculate();

User-defined variadic functions [3]

Functionf=newFunction("f(...) = sum( i, 1, [npar], par(i) )");Expressione=newExpression("f(1,2,3,4)",f);doublev=e.calculate();

User-defined recursion [3]

Functionfib=newFunction("fib(n) = iff( n>1, fib(n-1)+fib(n-2); n=1, 1; n=0, 0 ) )");Expressione=newExpression("fib(10)",fib);doublev=e.calculate();

Requirements [3]

Documentation

mXparser - source code

Source code is maintained and shared on GitHub. [5]

See also

Related Research Articles

<span class="mw-page-title-main">Bessel function</span> Families of solutions to related differential equations

Bessel functions, first defined by the mathematician Daniel Bernoulli and then generalized by Friedrich Bessel, are canonical solutions y(x) of Bessel's differential equation

<span class="mw-page-title-main">Euler's formula</span> Complex exponential in terms of sine and cosine

Euler's formula, named after Leonhard Euler, is a mathematical formula in complex analysis that establishes the fundamental relationship between the trigonometric functions and the complex exponential function. Euler's formula states that, for any real number x, one has

<span class="mw-page-title-main">Exponential function</span> Mathematical function, denoted exp(x) or e^x

The exponential function is a mathematical function denoted by or . Unless otherwise specified, the term generally refers to the positive-valued function of a real variable, although it can be extended to the complex numbers or generalized to other mathematical objects like matrices or Lie algebras. The exponential function originated from the operation of taking powers of a number, but various modern definitions allow it to be rigorously extended to all real arguments , including irrational numbers. Its ubiquitous occurrence in pure and applied mathematics led mathematician Walter Rudin to consider the exponential function to be "the most important function in mathematics".

<span class="mw-page-title-main">Logarithm</span> Mathematical function, inverse of an exponential function

In mathematics, the logarithm is the inverse function to exponentiation. That means that the logarithm of a number x to the base b is the exponent to which b must be raised to produce x. For example, since 1000 = 103, the logarithm base  of 1000 is 3, or log10 (1000) = 3. The logarithm of x to base b is denoted as logb (x), or without parentheses, logbx. When the base is clear from the context or is irrelevant it is sometimes written log x.

In mathematics, Catalan's constantG, is defined by

<span class="mw-page-title-main">Hyperbolic functions</span> Collective name of 6 mathematical functions

In mathematics, hyperbolic functions are analogues of the ordinary trigonometric functions, but defined using the hyperbola rather than the circle. Just as the points (cos t, sin t) form a circle with a unit radius, the points (cosh t, sinh t) form the right half of the unit hyperbola. Also, similarly to how the derivatives of sin(t) and cos(t) are cos(t) and –sin(t) respectively, the derivatives of sinh(t) and cosh(t) are cosh(t) and +sinh(t) respectively.

Lambert <i>W</i> function Multivalued function in mathematics

In mathematics, the Lambert W function, also called the omega function or product logarithm, is a multivalued function, namely the branches of the converse relation of the function f(w) = wew, where w is any complex number and ew is the exponential function. The function is named after Johann Lambert, who considered a related problem in 1758. Building on Lambert's work, Leonhard Euler described the W function per se in 1783.

<span class="mw-page-title-main">Exponentiation</span> Arithmetic operation

In mathematics, exponentiation is an operation involving two numbers: the base and the exponent or power. Exponentiation is written as bn, where b is the base and n is the power; this is pronounced as "b (raised) to the n". When n is a positive integer, exponentiation corresponds to repeated multiplication of the base: that is, bn is the product of multiplying n bases:

<span class="mw-page-title-main">Dynamic programming</span> Problem optimization method

Dynamic programming is both a mathematical optimization method and an algorithmic paradigm. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, from aerospace engineering to economics.

<span class="mw-page-title-main">Euler's constant</span> Constant value used in mathematics

Euler's constant is a mathematical constant, usually denoted by the lowercase Greek letter gamma, defined as the limiting difference between the harmonic series and the natural logarithm, denoted here by log:

In mathematics, a Gaussian function, often simply referred to as a Gaussian, is a function of the base form

<span class="mw-page-title-main">Separation of variables</span> Technique for solving differential equations

In mathematics, separation of variables is any of several methods for solving ordinary and partial differential equations, in which algebra allows one to rewrite an equation so that each of two variables occurs on a different side of the equation.

The Basel problem is a problem in mathematical analysis with relevance to number theory, concerning an infinite sum of inverse squares. It was first posed by Pietro Mengoli in 1650 and solved by Leonhard Euler in 1734, and read on 5 December 1735 in The Saint Petersburg Academy of Sciences. Since the problem had withstood the attacks of the leading mathematicians of the day, Euler's solution brought him immediate fame when he was twenty-eight. Euler generalised the problem considerably, and his ideas were taken up more than a century later by Bernhard Riemann in his seminal 1859 paper "On the Number of Primes Less Than a Given Magnitude", in which he defined his zeta function and proved its basic properties. The problem is named after Basel, hometown of Euler as well as of the Bernoulli family who unsuccessfully attacked the problem.

bc, for basic calculator, is "an arbitrary-precision calculator language" with syntax similar to the C programming language. bc is typically used as either a mathematical scripting language or as an interactive mathematical shell.

In mathematics, a fundamental solution for a linear partial differential operator L is a formulation in the language of distribution theory of the older idea of a Green's function.

von Mises distribution Probability distribution on the circle

In probability theory and directional statistics, the von Mises distribution is a continuous probability distribution on the circle. It is a close approximation to the wrapped normal distribution, which is the circular analogue of the normal distribution. A freely diffusing angle on a circle is a wrapped normally distributed random variable with an unwrapped variance that grows linearly in time. On the other hand, the von Mises distribution is the stationary distribution of a drift and diffusion process on the circle in a harmonic potential, i.e. with a preferred orientation. The von Mises distribution is the maximum entropy distribution for circular data when the real and imaginary parts of the first circular moment are specified. The von Mises distribution is a special case of the von Mises–Fisher distribution on the N-dimensional sphere.

<span class="mw-page-title-main">Multiple integral</span> Generalization of definite integrals to functions of multiple variables

In mathematics (specifically multivariable calculus), a multiple integral is a definite integral of a function of several real variables, for instance, f(x, y) or f(x, y, z).

<span class="mw-page-title-main">Transcendental equation</span> Equation whose side(s) describe a transcendental function

In applied mathematics, a transcendental equation is an equation over the real numbers that is not algebraic, that is, if at least one of its sides describes a transcendental function. Examples include:

This is a summary of differentiation rules, that is, rules for computing the derivative of a function in calculus.

In discrete calculus the indefinite sum operator, denoted by or , is the linear operator, inverse of the forward difference operator . It relates to the forward difference operator as the indefinite integral relates to the derivative. Thus

References