Contents
========

1. Expressions
2. Variables
3. Operators
4. Functions

-----------------------------------------------------------------------------
1. Expressions
==============

Well formed expressions are strings of constants (numbers), variables, 
and functions separated by operators.  Spaces are stripped from 
expressions before parsing.

Examples:

	'2*a'	ok '2 times variable a'
	'2 a'	illegal, interpreted as '2a' (not a valid variable name)
	'a*2'	ok 'variable a times 2'
	'a 2'	legal but (mis-)interpreted as variable 'a2'

-----------------------------------------------------------------------------
2. Variables
============

Valid variable names begin with a letter (a..z) or underscore (_) and 
may be followed by more of the same or digits (0..9).  Variables are 
case INsensitive.  The only restriction is that variable names may not 
contain the strings 'div' or 'mod' because these are interpreted as 
operators (eg. variable 'amodb' would be treated as 'a mod b').

-----------------------------------------------------------------------------
3. Operators
============

Operators obey the usual convention for precedence (1+2*3=7 -- not 9) as 
shown in the table.

Precedence	Operator
----------	--------
1         	()      	parentheses
2         	^       	power
3         	div,mod 	integer division, modulo
4         	*,/     	multiplication, real division
5        	+,-     	addition, subtraction
6        	-       	unary negation


-----------------------------------------------------------------------------
4. Functions
============

Functions are case INsensitive.  The currently defined functions are:
(notation: the variables a and b represent the first and second function
parameters, respectively)

abs(a)
------
- absolute value

arctan(a)
---------
- trigonometric inverse (arc) tangent.  Returns angle in radians.

arg(a,b)
--------
- returns the direction to the coordinates (a,b) from the origin in 
radians.  Measured (up) from the positive 'x'-axis.

ceil(a)
-------
- ceiling.  Smallest integer not less than a.

cos(a)
------
- trigonometric cosine.  Argument a must be in radians.

cosh(a)
-------
- hyperbolic cosine

cotan(a)
--------
- trigonometric cotangent.  Argument a must be in radians.

exp(a)
------
- exponential

floor(a)
--------
- floor.  Largest integer not greater than a.

heav(a)
-------
- Heaviside.  Returns 0 if a<0, else 1.

int(a)
------
- truncation.  Same as trunc(a).

ln(a)
-----
- natural logarithm (base e)

log10(a)
--------
- logarithm base 10

log2(a)
-------
- logarithm base 2

logN(a,b)
---------
- logarithm of a base b

max(a,b)
--------
- maximum value of a and b

min(a,b)
--------
- minimum value of a and b

random(a)
---------
- random.  Returns a random number between 0 and 1 (ignores a).

rnd(a)
------
- random.  Returns a random number between 0 and a.

sign(a)
-------
- returns -1 if a<0, 1 if a>0, or 0 if a=0

sin(a)
------
- trigonometric sine.  Argument a must be in radians.

sinh(a)
-------
- hyperbolic sine

sqrt(a)
-------
- square root

tan(a)
------
- trigonometric tangent.  Argument a must be in radians.

trunc(a)
--------
- truncation.  Same as int(a).

zero(a)
-------
- returns 0 if a=0, else 1



Rik Blok
blok@physics.ubc.ca
http://www.physics.ubc.ca/~blok/