The QtiPlot Handbook
Prev |  | Next

# Chapter 7. Mathematical Expressions and Scripting

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 fundamental physical constants, operators and functions. Please note that the fundamental constants cannot be redefined. Doing so will raise an error message.

Table 7-1. Predefined Fundamental Physical Constants

Name | Description
--- | ---
c | The speed of light in vacuum
eV | The energy of 1 electron volt
g | The standard gravitational acceleration on Earth
G | The gravitational constant
h | Planck's constant
hbar | Planck's constant divided by 2 pi
k | The Boltzmann constant
Na | Avogadro's number
R0 | The molar gas constant
V0 | The standard gas volume
Ry | The Rydberg constant, in units of energy

Table 7-2. Supported Mathematical Operators

Name | Description
--- | ---
+ | Addition
- | Substraction
* | Multiplication
/ | Division
^ | Exponentiation (raise a to the power of b)
and | logical and (returns 0 or 1)
or | logical or (returns 0 or 1)
xor | logical 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-3. Mathematical Functions

Name | Description
--- | ---
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-4. Non-Mathematical Functions

Name | Description
--- | ---
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.

Prev | Home | Next
Interpolation |  | Python