General Purpose Functions

FUNCTION DEFINITION
abs Absolute value of x. (eg: abs(x))
avg Average of all the inputs. (eg: avg(x,y,z,w,u,v) == (x + y + z + w + u + v) / 6)
ceil Smallest integer that is greater than or equal to x.
clamp Clamp x in range between r0 and r1, where r0 < r1. (eg: clamp(r0,x,r1))
equal Equality test between x and y using normalised epsilon
erf Error function of x. (eg: erf(x))
erfc Complimentary error function of x. (eg: erfc(x))
exp $e^x$ (eg: exp(x))
expm1 $e^{x-1}$ where $x$ is very small. (eg: expm1(x))
floor Largest integer that is less than or equal to x. (eg: floor(x))
frac Fractional portion of x. (eg: frac(x))
hypot $\sqrt{x^2+y^2}$ (eg: hypot(x,y) = sqrt(x*x + y*y))
iclamp Inverse-clamp x outside of the range r0 and r1. Where r0 < r1. If x is within the range it will snap to the closest bound. (eg: iclamp(r0,x,r1) $=\left\{\begin{array}{ccc}
r0 & \mathrm{if} & x\le r0\\
x & \mathrm{if} & r0\le x \le r1\\
r1 & \mathrm{if} & x\ge r1\\
\end{array}\right.$ )
inrange In-range returns 'true' when $x$ is within the range $[r_0,r_1]$. Where $r_0 < r_1$. (eg: inrange(r0,x,r1))
log Natural logarithm $\ln x$. (eg: log(x))
log10 $\log_{10}x$. (eg: log10(x))
log1p $\ln (1+x)$, where $x$ is very small. (eg: log1p(x))
log2 $\log_2x$. (eg: log2(x))
logn $\log_nx$, where $n$ is a positive integer. (eg: logn(x,8))
max Largest value of all the inputs. (eg: max(x,y,z,w,u,v))
min Smallest value of all the inputs. (eg: min(x,y,z,w,u))
mul Product of all the inputs. (eg: mul(x,y,z,w,u,v,t) == (x * y * z * w * u * v * t))
ncdf Normal cumulative distribution function. (eg: ncdf(x))
nequal Not-equal test between $x$ and $y$ using normalised epsilon
pow $x^y$. (eg: pow(x,y) == x ^ y)
root $\sqrt[n]{x}$, where $n$ is a positive integer. (eg: root(x,3) == x^(1/3))
round Round $x$ to the nearest integer. (eg: round(x))
roundn Round $x$ to $n$ decimal places (eg: roundn(x,3)) where $n > 0$ is an integer. (eg: roundn(1.2345678,4) == 1.2346)
sgn Sign of $x$, $-1$ where $x < 0$, +1 where $x > 0$, else zero. (eg: sgn(x))
sqrt $\sqrt{x}$, where $x >= 0$. (eg: sqrt(x))
sum Sum of all the inputs. (eg: sum(x,y,z,w,u,v,t) == (x + y + z + w + u + v + t))
swap  
<=> Swap the values of the variables x and y and return the current value of y. (eg: swap(x,y) or x <=> y)
trunc Integer portion of x. (eg: trunc(x))