Procedures Details | <Prev Next> |

General mathematical expressions can be used in
several contexts, such as expressing constraints in least squares
fitting, and Custom
Population Functions, Custom
Width Functions, Custom
Transition Functions, Lineshape
Functions or Custom
Lineshape Functions. Each context has some specific
variables introduced, but the same logic is otherwise used for all
expressions:

- The function is held in the comment field for the object; in the constants window an enlarged text window replaces the normal comments window.
- Parameter names can be used to include parameter values in
expressions. To find the name of a parameter, right click on it
in the constants window and
select "Show Full Name".
The name is also copied to the clipboard. Depending on the
context, parts of the parameter name can be omitted if no
ambiguity is introduced as to the parameter concerned. Quotes
might be needed around the parameter name if it contains special
characters, as in
`"NH3.NH3.s.<0-|J+-^6|0->.Value"`.

- Any unrecognised names are typically created as variables. To
rename or delete created variables, right click on the variable
and select rename or remove as required.

- The standard mathematical operators are available: + - * /, with power expressible as ^ or **.
- The standard functions
`sqrt``, sqr,``abs``,``sin``, cos, tan, acos, asin, atan, arccos, arcsin, arctan, exp, ln, log10, ceil, floor, round,``factorial, sinh, cosh, tanh`are available. See also the special functions below.

- The comparison operators =, <>, !=, >, <, >=
and <= evaluate to 1 for true, 0 for false. To express a
conditional combine these with multiply and add, so for example
`(a>b)*a+(``a<=b)*b`would give the maximum of`a`and`b`. - All arithmetic is done in double precision.
- Comments are # or // to end of line, or enclosed in {...} or /* ... */
- A simple test calculator is available from "
`View, Calculator`".

int(a) |
Integer part of a; number is closer
to zero than a (or equal to a). |

frac(a) |
a - int(a) |

% |
modulus operator: a % b = frac(a/b)*b |

mod(a,b) |
a % b except if a < 0
in which case b-frac(|a|/b)*b is used. |

a xor b |
bitwise exclusive or of a and b |

pi |
3.14159... |

min(a,b,c...) |
The minimum value of all the arguments |

max(a,b,c...) |
The maximum value of all the arguments |

poly(x,a0,a1,a2...) |
a_{0}+a_{1}.x+a_{2}.x^{2}+... |

lor(x,l) |
Lorenztian function with FWHM l. |

gau(x,g) |
Gaussian function with FWHM g. |

voigt(x,l,g) |
Voigt profile at offset x from the
line centre. l is the FWHM of the Lorenztian
component, g of the Gaussian. |

air(s) |
Air wavelength/nm given vacuum wavenumber s/cm^{-1}.
The refractive index is taken from from B Edlen, Metrologia,
2, 71 (1966). |

vac(l) |
Vacuum wavenumber/cm^{-1} given air
wavelength in nm. |

atan2(x,y) |
atan(x/y), but with a -π...π result
range. |

threej(j1,m1,j2,m2,j3,m3) |
Wigner 3-j function |

cg(j1,m1,j2,m2,j3,m3) |
Clebsch-Gordan coefficient = (-1)^{j1-j2+m3}(2j_{3}+1)^{½}threej(j1,m1,j2,m2,j3,-m3) |

sixj(j1,j2,j3,j4,j5,j6) |
Wigner 6-j function |

ninej(j11,j12,j13,j21,j22,j23,j31,j32,j33) |
Wigner 9-j function |

Selected fundamental constants (in SI units) are available in many contexts, though not all to avoid confusion:

a0 |
Bohr radius/m |

c |
Speed of light |

ee |
Charge on the electron |

ep |
Permittivity of a vacuum |

ge |
g value for an electron |

gg |
Gravitational Constant |

f |
Faraday Constant |

k |
Boltzmann Constant |

l |
Avogadro's Number |

r |
Gas Constant |

h |
Planck constant |

hc |
h/2π |

me |
mass of electron |

mn |
mass of neutron |

mp |
mass of proton |

mub |
Bohr magneton |

mun |
nuclear magneton |

rydberg |
Rydberg constant/m^{-1} |

u |
Atomic mass unit/kg |

See also:

- Variables objects, which contain global parameters typically used to constrain fits.
- Table objects which can be used for tables of values.

A `nDebug` flag is available in each
object that uses an expression. If non zero, that the values of
all the variables and the value of the function on each evaluation
will be written to the log window. The value specifies the number
of times this is done; use `View, Clear Cache` to reset
the count if necessary. Negative values have special
interpretation:

- -1 outputs every evaluation, which can produce a lot of output.
- -2 only prints evaluations with a non-zero result
- -3 only prints evaluations where the result differs from the
standard result.