Fractal program functions

Functions

sin(z), cos(z), tan(z), sec(z), csc(z), cot(z)Add an 'h' to the end of each to get the hyperbolic equivalent. Add an 'a' to the start of each to get the inverse. (Note: the inverse functions are not yet implemented for complex numbers.)
ln(z), log(z)Natural log
exp(z)Exponential function e^z.
abs(z)Absolute value (real or complex)
absn(z)For reals, it is the same as abs(z). For complex numbers, it returns abs(z)+i*im(z), which makes for quite interesting fractals (much more interesting than abs(z)).
absn(z)For reals, it is the same as abs(z). For complex numbers, it returns re(z)+abs(z)*i.
arg(z)Argument (of a complex number). Returns 0 if z is real.
argn(z)Returns arg(z)+i*im(z). Analogous to absn(z).
conj(z)Complex conjugate
re(z)Real part of a complex number
im(z)Imaginary part of a complex number
floor(z)For reals, it returns the greatest integer less than or equal to z. For a complex number z=x+iy, it returns floor(x)+i*floor(y).
ceil(x)For reals, it returns the least integer greater than or equal to z. For a complex number z=x+iy, it returns ceil(x)+i*ceil(y).
round(z)For reals, it rounds z to the nearest integer. For a complex number z=x+iy, it returns round(x)+i*round(y).
max(x,y)For reals, it returns the larger of x and y. For complex numbers it returns the one with a larger absolute value, or the second argument if both have the same absolute value.
min(x,y)Like max(x,y) above
sqrt(z)Square root
cbrt(z)Cube root. Not the same as entering in z^(1/3) since the C compiler won't do pow(z,1/3) if z is negative.
nroot(z)nth root. Not the same as entering in z^(1/n) since the C compiler won't do pow(z,1/n) if z is negative.
square(x)Returns the square of a number. This is a little faster than x^2 if speed is really an issue.
cube(x)Returns the cube of a number. This is a little faster than x^3 if speed is really an issue.
sgn(z)Returns z/|z|. For reals, this is -1 if z<0, 1 if z>0 and 0 if z=0. For a complex numbers z=x+iy, this is a unit vector in the same direction as z.
ncr(n,r)Returns n choose r. For complex numbers, it just uses the real parts and ignores the imaginary parts. It does not extend the definition of ncr to complex numbers using the gamma function, though it may do so in the future.
gamma(z)Gamma function. Not currently implemented for complex numbers.
lgamma(z)Logarithmic Gamma function. Not currently implemented for complex numbers.
binom(n,p,r)Returns (n choose r)*p^r(1-p)^(n-r). Not implemented for complex numbers.
sbinom(n,p,k)Returns sum r=0 to r=k of (n choose r)*p^r(1-p)^(n-r). Not implemented for complex numbers.
normal(x,y,m,s,n)For a normal random variable X w/ mean m and standard deviation s, returns prob(x<X<y). It does this by numerical integration, and the parameter n is the number of steps to do (n=100 gives an answer typically correct to several decimal places). It is not defined for complex numbers, though it probably could be.
rand(z)returns a random integer between 0 and z. Best used with positive integers. For a complex number z=x+iy it returns a random "complex integer" whose real part is between 0 and x, and whose imaginary part is between 0 and y.
riem(z,k)This returns sum n=1 to k of sin(k^2*x)/k^2, a function which is continuous everywhere but only differentiable on a set of measure zero. Defined for real or complex z.
riemc(z,k)This returns sum n=1 to k of cos(k^2*x)/k^2.
ind(z)For reals, it is the indicator function of (0,1) (sometimes called a characteristic function). It returns 1 if x is in (0,1), and 0 otherwise. For complex numbers, it is the indicator function of (0,1)x(0,1). For z=x+iy it returns 1 if x and y are both between 0 and 1, and 0 otherwise.
indc(z)Indicator function of the unit circle. It's the same as ind(z) for reals, and for complex numbers, it returns 1 if abs(z)<1, and 0 otherwise.

Operators

For complex numbers, operators other than +,-,*,/,^ operate on the real and imaginary parts separately. For example, for z=x+iy and w=a+bi, the operator & acts as (x&a)+i*(y&b)).

+,-,*,/addition, subtraction, multiplication, division
^exponentiation (e.g., 5^2=25)
%modulo (e.g., 27%5=2, the remainder when 27 is divided by 5)
!factorial
< <=,>,>=,==,!=  logical operators (e.g., (3>1 returns 1 but 1>3 returns 0)
&&,||logical and,or
&,|,#bitwise and, or, xor
!logical ! on left (!x=1 if x=0 and 0 otherwise), and factorial on right
~one's complement

For example, the function which is equal to sin(x) for x<2 and x^2 otherwise: x*(x<2)+x^2*(x>=2). Note also that the constants pi, _e, root2, and root3 are built into the program.