The function can use arithmetic like a+b, a*b, a^2/(b-1), etc. It can also use functions like sin(x), cos(x), abs(x), exp(x), log(x), sqrt(x), tan(x), floor(x), ceil(x), mod(x,y), max(x,y,...), and min(x,y,...).
It can also use conditional expressions like (a > 5) ? a+1 : b-2.
The tri(x) function is like sin(x), but generates a triangle waveform.
The saw(x) function is like sin(x), but generates a sawtooth waveform.
The step(x) function is 0 if x < 0, and 1 otherwise. (Equivalent to x >= 0). The step(x,y) function is 1 if 0 < x < y, and 0 otherwise. (Equivalent to 0 < x && x < y).
The clamp(x,lo,hi) function is equal to min(max(x, lo), hi).
The select(x,a,b) function is equal to b if x is greater than zero, and a otherwise. So it's the same as (x > 0) ? b : a.
The pwl(x,x0,y0,x1,y1,x2,y2,...,xn,yn) function is short for piece-wise linear, and works as follows. If x < x0, then the result is y0. If x0 < x < x1, then the result is a linear interpolation between y0 and y1. If x1 < x < x2, the result is a linear interpolation between y1 and y2, etc. If x > xn, then the result is yn. For example, in the simplest case, pwl(t,0,0,.1,5) is a waveform that starts at 0 at time 0 and then ramps to 5 over 100ms, then stays at 5.
dadt, dbdt, etc. are equal to the time derivative of a, b, etc. lasta, lastb, etc. are equal to the value of a, b, etc. in the previous timestep. lastoutput is equal to value of the output function in the previous timestep. Examples: