spec

Software for Diffraction

2.4.5.1. - Math Functions



exp(x), exp10(x)
Returns exand 10xrespectively.

log(x), log10(x)
Returns the natural logarithm and the base 10 logarithm of x respectively.

sqrt(x)
Returns the square root of x.

pow(x, y)
Returns xy.

fabs(x)
Returns the absolute value of x.

int(x)
Returns the integer part of x. The integer part is formed by truncation towards zero.

rand()
Returns a random integer between 0 and 32767.

rand(x)
If x is positive, returns a random integer between 0 and x, inclusive. If x is negative, returns a random integer between -x and x, inclusive. Values of x greater than 32767 or less than -16383 are set to those limits. If x is zero, zero is returned. The C-library rand() function is used to obtain the values. The seed is set to the time of day on the first call. The randomness (or lack thereof) of the numbers obtained is due to the C library implementation.

srand(seed)
Sets the seed value for the random number generator used by the rand() function to the integer value seed. This function allows the same sequence of random numbers to be generated reproducibly by resetting the seed to the same value.

sin(x), cos(x), tan(x)
Returns the sine, cosine and tangent, respectively, of the argument x, which must be in radians.

asin(x), acos(x), atan(x)
Returns the arc sine, arc cosine and arc tangent, respectively, of the argument x. The return value is in radians. asin() and atan() return values in the range -π/2 to π/2, while acos() returns values from 0 to π.


atan2(y, x)
Returns the arc tangent of y/x using the signs of the arguments to determine the quadrant of the return value. The return value is in the range -π to π. Having both y and x zero is an error.