Mathematical functions

AnyLogic provides a comprehensive set of mathematical functions. The table below gives a brief descriptions of the functions, for the details you may refer to the online Javadoc on Math class.

Return type

Name

Description

double

abs(double a)

Returns the absolute value of a double value.

int

abs(int a)

Returns the absolute value of an int value.

double

acos(double a)

Returns the arc cosine of a value; the returned angle is in the range 0.0 through .

Parameters: a - the value whose arc cosine is to be returned.

double

asin(double a)

Returns the arc sine of a value; the returned angle is in the range
-/2 through /2.

Parameters: a - the value whose arc sine is to be returned.

double

atan(double a)

Returns the arc tangent of a value; the returned angle is in the range -/2 through /2.

Parameters: a - the value whose arc tangent is to be returned.

double

atan2(double y, double x)

Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).

double

cbrt(double a)

Returns the cube root of a double value.

double

ceil(double a)

Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

double

cos(double a)

Returns the trigonometric cosine of an angle.

Parameters: a - an angle, in radians.

double

cosh(double x)

Returns the hyperbolic cosine of a double value.

Parameters: x - The number whose hyperbolic cosine is to be returned.

double

exp(double a)

Returns Euler's number e raised to the power of a double value.

double

expm1(double x)

Returns ex -1.

double

floor(double a)

Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.

double

gammaLog(double x)

Returns the natural logarithm of the gamma function of x: ln(Γ(x)). The gamma function is an extension of the factorial function that works on all positive values of x. If n is a positive integer, then: Γ(n) = (n - 1)!
The gammaLog function may be useful in System Dynamics models for computing combinatorial factors.

int

getExponent(double d)

Returns the unbiased exponent used in the representation of a double.

double

hypot(double x, double y)

Returns sqrt(x2 +y2) without intermediate overflow or underflow.

double

limit(double min, double x, double max)

Returns x if it is within [min,max] interval, otherwise returns the closest bound.

double

limitMax(double x, double max)

Returns x if it is less or equal to max, otherwise returns max. May be more self-explanatory than the function min as explicitly says "x is right-limited by max".

double

limitMin(double min, double x)

Returns x if it is greater or equal to min, otherwise returns min. May be more self-explanatory than the function max as explicitly says "x is left-limited by min".

double

log(double a)

Returns the natural logarithm (base e) of a double value.

double

log10(double a)

Returns the base 10 logarithm of a double value.

double

log1p(double x)

Returns the natural logarithm of the sum of the argument and 1.

double

max(double a, double b)

Returns the greater of two double values.

int

max(int a, int b)

Returns the greater of two int values.

double

min(double a, double b)

Returns the smaller of two double values.

int

min(int a, int b)

Returns the smaller of two int values.

double

pow(double a, double b)

Returns the value of the first argument raised to the power of the second argument.

double

quantum(double value, double quantizer)

Returns the number smaller (by absolute value) than or equal to value that is an integer multiple of quantizer. If quantizer is less than or equal to zero, then value is returned unchanged.

Parameters: value - the value; quantizer - quantizer, defining the interval between possible values returned by the function: quantizer, quantizer*2, ...

double

random()

Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.

double

rint(double a)

Returns the double value that is closest in value to the argument and is equal to a mathematical integer.

double

scalb(double d, int scaleFactor)

Return d 2scaleFactor rounded as if performed by a single correctly rounded floating-point multiply to a member of the double value set.

double

signum(double d)

Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero.

double

sin(double a)

Returns the trigonometric sine of an angle.

Parameters: a - an angle, in radians.

double

sinh(double x)

Returns the hyperbolic sine of a double value.

Parameters: x - The number whose hyperbolic sine is to be returned.

double

sqrt(double a)

Returns the correctly rounded positive square root of a double value.

double

tan(double a)

Returns the trigonometric tangent of an angle.

Parameters: a - an angle, in radians.

double

tanh(double x)

Returns the hyperbolic tangent of a double value.

double

toDegrees(double angrad)

Converts an angle measured in radians to an approximately equivalent angle measured in degrees.

Parameters: angrad - an angle, in radians

double

toRadians(double angdeg)

Converts an angle measured in degrees to an approximately equivalent angle measured in radians.

Parameters: angdeg - an angle, in degrees

double

xidz(double a, double b, double x)

Tries to divide the first argument by the second. If the result is infinity or not a number, returns the third argument (x), otherwise returns the division result.

double

zidz(double a, double b)

Tries to divide the first argument by the second. If the result is infinity or not a number, returns 0, otherwise returns the division result.