Chapter 7. Mathematical Expressions and Scripting

Table of Contents

muParser
Supported Mathematical Functions
Python
The Initialization File
Python Basics
Defining Functions and Control Flow
Mathematical Functions
Accessing QtiPlot's functions from Python

Starting with version 0.8.7, QtiPlot supports different interpreters for evaluating mathematical expressions and for executing scripts. On Windows currently only evaluation of mathematical expressions using muParser is supported. Support for scripts using the Python programming language is only available for Linux and Mac OS X. When the port of QtiPlot to Qt4 will be ready this feature will also be supported on Windows systems.

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)

Supported Mathematical Functions

Table 7.2. Supported 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).
if(e1,e2,e3)if e1 is true, e2 is executed else e3 is executed.
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