Mxparser

Last updated
MathParser.org-mXparser
Original author(s) Mariusz Gromada
Initial releaseJanuary 2010;14 years ago (2010-01)
Stable release
6.1.0 / 19 October 2024;1 day ago (2024-10-19)
Repository github.com/mariuszgromada/MathParser.org-mXparser/
Written in Java, C#, C++
Platform JVM, Android, C++, .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 for an arbitrary complex number , which represents the order of the Bessel function. Although and produce the same differential equation, it is conventional to define different Bessel functions for these two values in such a way that the Bessel functions are mostly smooth functions of .

In calculus, the chain rule is a formula that expresses the derivative of the composition of two differentiable functions f and g in terms of the derivatives of f and g. More precisely, if is the function such that for every x, then the chain rule is, in Lagrange's notation, or, equivalently,

In mathematics, the derivative is a fundamental tool that quantifies the sensitivity of change of a function's output with respect to its input. The derivative of a function of a single variable at a chosen input value, when it exists, is the slope of the tangent line to the graph of the function at that point. The tangent line is the best linear approximation of the function near that input value. For this reason, the derivative is often described as the instantaneous rate of change, the ratio of the instantaneous change in the dependent variable to that of the independent variable. The process of finding a derivative is called differentiation.

<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 where e is the base of the natural logarithm, i is the imaginary unit, and cos and sin are the trigonometric functions cosine and sine respectively. This complex exponential function is sometimes denoted cis x. The formula is still valid if x is a complex number, and is also called Euler's formula in this more general case.

<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 to baseb is the inverse function of exponentiation with base b. 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.

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.

In calculus, and more generally in mathematical analysis, integration by parts or partial integration is a process that finds the integral of a product of functions in terms of the integral of the product of their derivative and antiderivative. It is frequently used to transform the antiderivative of a product of functions into an antiderivative for which a solution can be more easily found. The rule can be thought of as an integral version of the product rule of differentiation; it is indeed derived using the product rule.

In mathematics, a Gaussian function, often simply referred to as a Gaussian, is a function of the base form and with parametric extension for arbitrary real constants a, b and non-zero c. It is named after the mathematician Carl Friedrich Gauss. The graph of a Gaussian is a characteristic symmetric "bell curve" shape. The parameter a is the height of the curve's peak, b is the position of the center of the peak, and c controls the width of the "bell".

In mathematics and computer algebra, automatic differentiation, also called algorithmic differentiation, computational differentiation, is a set of techniques to evaluate the partial derivative of a function specified by a computer program.

<span class="mw-page-title-main">Iterated function</span> Result of repeatedly applying a mathematical function

In mathematics, an iterated function is a function that is obtained by composing another function with itself two or several times. The process of repeatedly applying the same function is called iteration. In this process, starting from some initial object, the result of applying a given function is fed again into the function as input, and this process is repeated.

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">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

In mathematical logic, a term denotes a mathematical object while a formula denotes a mathematical fact. In particular, terms appear as components of a formula. This is analogous to natural language, where a noun phrase refers to an object and a whole sentence refers to a fact.

This article describes the features in the programming language Haskell.

exp4j is a small Java library for evaluation of mathematical expressions. It implements Dijkstra's Shunting-yard algorithm to translate expressions from infix notation to Reverse Polish notation and calculates the result using a simple Stack algorithm.

References