Numeric functions

Provides a reference for numeric functions in the OPL language.

Note:

For C/C++ programmers: Most of the numeric functions are wrap-ups for standard math library functions.

Table 1. Numeric functions
Syntax Effect
Math.abs(x) Returns the absolute value of x.
Math.max(x,y) Math.max(x, y) returns the larger of x and y.
Math.min(x,y) Math.max(x, y) returns the smaller of x and y.
Math.random() Returns a pseudo-random number between 0, inclusive, and 1, exclusive.
Math.ceil(x) Math.ceil(x) returns the smallest integer value greater than or equal to x.
Math.floor(x) Math.floor(x) returns the greatest integer value less than or equal to x.
Math.round(x) Math.round(x) returns the nearest integer value to x.
Math.sqrt(x) Returns the square root of x.
Math.sin(x) Math.sin(x) returns the trigonometric function sine of a radian argument.
Math.cos(x) Math.cos(x) returns the trigonometric function cosine of a radian argument.
Math.tan(x) Math.tan(x) returns the trigonometric function tangent of a radian argument.
Math.asin(x) Math.asin(x) returns the arcsine of x in the range -pi/2 to pi/2.
Math.acos(x) Math.acos(x) returns the arc cosine of x in the range 0 to pi.
Math.atan(x) Math.atan(x) returns the arc tangent of x in the range -pi/2 to pi/2.
Math.atan2(y,x) Math.atan2(y, x) converts rectangular coordinates (x, y) to polar coordinates (r, a) by computing a as an arc tangent of y/x in the range -pi to pi.
Math.exp(x) Math.exp(x) computes the exponential function.
Math.log(x) Math.log(x) computes the natural logarithm of x.
Math.pow(x,y) Math.pow(x, y) computes x raised to the power y.