Chapter 7. Mathematical Expressions and Scripting

Table of Contents
muParser
Python

QtiPlot supports two different interpreters for evaluating mathematical expressions and for executing scripts: muParser and Python. muParser can be only used for the evaluation of mathematical expressions, whereas Python can be used to execute scrips. The default interpreter is muParser therefore if you want to execute scripts you should first enable the Python scripting engine via the Scripting language dialog. Also, you can define the default scripting interpreter via the General tab of the Preferences dialog.

muParser

The constants _e=e=E and _pi=pi=PI=Pi are defined, as well as the following operators and functions.

Table 7-1. Supported Mathematical Operators

NameDescription
+Addition
-Substraction
*Multiplication
/Division
^Exponentiation (raise a to the power of b)
andlogical and (returns 0 or 1)
orlogical or (returns 0 or 1)
xorlogical exclusive or (returns 0 or 1)
<less then (returns 0 or 1)
<=less then or equal (returns 0 or 1)
==equal (returns 0 or 1)
>=greater then or equal (returns 0 or 1)
>greater then (returns 0 or 1)
!=not equal (returns 0 or 1)

Table 7-2. Mathematical Functions

NameDescription
abs(x)absolute value of x
acos(x)inverse cosinus
acosh(x)inverse hyperbolic cosinus
asin(x)inverse sinus
asinh(x)inverse hyperbolic sinus
atan(x)inverse tangent
atanh(x)inverse hyperbolic tangent
avg(x1,x2,x3,...)average value, this command accept a list of arguments separated by commas
bessel_j0(x)Regular cylindrical Bessel function of zeroth order, J0(x).
bessel_j1(x)Regular cylindrical Bessel function of first order, J1(x).
bessel_jn(x,n)Regular cylindrical Bessel function of nth order, Jn(x).
bessel_y0(x)Irregular cylindrical Bessel function of zeroth order, Y0(x) for x>0.
bessel_y1(x)Irregular cylindrical Bessel function of first order, Y1(x) for x>0.
bessel_yn(x,n)Irregular cylindrical Bessel function of nth order, Yn(x) for x>0.
beta (a,b)Computes the Beta Function, B(a,b) = Gamma(a)*Gamma(b)/Gamma(a+b) for a > 0 and b > 0.
cos(x)cosinus of x
cosh(x)hyperbolic cosinus of x
erf(x)error function of x
erfc(x)Complementary error function erfc(x) = 1 - erf(x).
erfz(x)The Gaussian probability density function Z(x).
erfq(x)The upper tail of the Gaussian probability function Q(x).
exp(x)Exponential function: e raised to the power of x.
gamma(x)Computes the Gamma function, subject to x not being a negative integer
gammaln(x)Computes the logarithm of the Gamma function, subject to x not a being negative integer. For x<0, log(|Gamma(x)|) is returned.
hazard(x)Computes the hazard function for the normal distribution h(x) = erfz(x)/erfq(x).
ln(x)natural logarythm of x
log(x)decimal logarythm of x
log2(x)base 2 logarythm of x
min(x1,x2,x3,...)Minimum of the list of arguments
max(x1,x2,x3,...)Maximum of the list of arguments
rint(x)Round to nearest integer.
sign(x)Sign function: -1 if x<0; 1 if x>0.
sin(x)sinus of x
sinh(x)hyperblic sinus of x
sqrt(x)square root of x
tan(x)tangent of x
tanh(x)hyperbolic tangent of x

Table 7-3. Non-Mathematical Functions

NameDescription
cell(a,b)In the contex of a matrix, returns the value at row a and column b. In the context of a table, returns the value at column a and row b (remember that tables use column logic). Everywhere else, this function is undefined.
col(c)Only works in the context of a table. Returns the value at column c and row i (the current row) in the context table. c can either be the column's number, or its name in doublequotes.
if(e1,e2,e3)if e1 is true, e2 is executed else e3 is executed.
tablecol(t,c)Only works in the context of a table. Returns the value at column c and row i (the current row) in the table t. t is the table's name in doublequotes, c is either the column's number or its name in doublequotes.