math

Mathematical functions for real numbers.

Summary
mathMathematical functions for real numbers.
Constants
PiThe value of Pi to 34 significant digits.
Functions
absAbsolute value.
acosInverse cosine (arc cos).
acoshInverse hyperbolic cosine (arc cosh).
asinInverse sine (arc sin).
asinhInverse hyperbolic sine (arc sinh).
atanInverse tangent (arc tan).
atanhInverse hyperbolic tangent (arc tanh).
atan2Inverse tangent (arc tan) of y/x.
cbrtCube root.
ceilCeiling function.
cosCosine.
coshHyperbolic cosine.
erfError function.
erfcComplementary error function.
expExponentiation.
exp2Exponentiation (base 2).
expm1Calculates exp(x)-1.0.
floorFloor function.
frexpDecomposes a floating point number into a normalised fraction and an integral power of 10.
hypotHypotenuse.
intdivInteger division with rounding toward zero.
ldexpMultiplies a floating point value x by the number 10 raised to the exp power.
lgammaLog gamma function.
logLogarithm.
log10Logarithm (base 10).
log1pComputes the natural (base e) logarithm of 1+arg.
log2Logarithm (base 2).
maxReturn the greater of two numbers.
minReturn the lesser of two numbers.
nearbyintReturns an integer close to x by rounding.
oddReturn TRUE if the given number is odd.
powmodCalculate modular exponentiation.
roundRound a number to a specified number of decimal places.
signReturns -1 if x is negative, 0 if x is 0, or 1 if x is positive.
sinSine.
sinhHyperbolic sine.
sqrtSquare root.
tanTangent.
tanhHyperbolic tangent.
tgammaGamma function.
truncTruncate to integer (effectively, round toward zero).

Constants

Pi

The value of Pi to 34 significant digits.

Functions

abs

DECLARE NATIVE FUNCTION abs(x: Number): Number

Absolute value.

Reference

http://mathworld.wolfram.com/AbsoluteValue.html

Example

ASSERT math.abs(-5) = 5

acos

DECLARE NATIVE FUNCTION acos(x: Number): Number

Inverse cosine (arc cos).

Reference

http://mathworld.wolfram.com/InverseCosine.html

acosh

DECLARE NATIVE FUNCTION acosh(x: Number): Number

Inverse hyperbolic cosine (arc cosh).

Reference

http://mathworld.wolfram.com/InverseHyperbolicCosine.html

asin

DECLARE NATIVE FUNCTION asin(x: Number): Number

Inverse sine (arc sin).

Reference

http://mathworld.wolfram.com/InverseSine.html

asinh

DECLARE NATIVE FUNCTION asinh(x: Number): Number

Inverse hyperbolic sine (arc sinh).

Reference

http://mathworld.wolfram.com/InverseHyperbolicSine.html

atan

DECLARE NATIVE FUNCTION atan(x: Number): Number

Inverse tangent (arc tan).

Reference

http://mathworld.wolfram.com/InverseTangent.html

atanh

DECLARE NATIVE FUNCTION atanh(x: Number): Number

Inverse hyperbolic tangent (arc tanh).

Reference

http://mathworld.wolfram.com/InverseHyperbolicTangent.html

atan2

DECLARE NATIVE FUNCTION atan2( y,
x: Number): Number

Inverse tangent (arc tan) of y/x.  This two-argument form avoids problems where x is near 0.

Reference

http://mathworld.wolfram.com/InverseTangent.html

cbrt

DECLARE NATIVE FUNCTION cbrt(x: Number): Number

Cube root.

Refrence

http://mathworld.wolfram.com/CubeRoot.html

ceil

DECLARE NATIVE FUNCTION ceil(x: Number): Number

Ceiling function.

Reference

http://mathworld.wolfram.com/CeilingFunction.html

cos

DECLARE NATIVE FUNCTION cos(x: Number): Number

Cosine.

Reference

http://mathworld.wolfram.com/Cosine.html

cosh

DECLARE NATIVE FUNCTION cosh(x: Number): Number

Hyperbolic cosine.

Reference

http://mathworld.wolfram.com/HyperbolicCosine.html

erf

DECLARE NATIVE FUNCTION erf(x: Number): Number

Error function.

Reference

http://mathworld.wolfram.com/Erf.html

erfc

DECLARE NATIVE FUNCTION erfc(x: Number): Number

Complementary error function.

Reference

http://mathworld.wolfram.com/Erfc.html

exp

DECLARE NATIVE FUNCTION exp(x: Number): Number

Exponentiation.

Reference

http://mathworld.wolfram.com/Exponentiation.html

exp2

DECLARE NATIVE FUNCTION exp2(x: Number): Number

Exponentiation (base 2).

Reference

http://mathworld.wolfram.com/Exponentiation.html

expm1

DECLARE NATIVE FUNCTION expm1(x: Number): Number

Calculates exp(x)-1.0.  This function avoids numeric accuracy problems where x is close to zero.

Reference

http://mathworld.wolfram.com/Exponentiation.html

floor

DECLARE NATIVE FUNCTION floor(x: Number): Number

Floor function.

Reference

http://mathworld.wolfram.com/FloorFunction.html

frexp

DECLARE NATIVE FUNCTION frexp(x: Number,
OUT exp: Number): Number

Decomposes a floating point number into a normalised fraction and an integral power of 10.

hypot

DECLARE NATIVE FUNCTION hypot(x: Number,
y: Number): Number

Hypotenuse.  Calcuates sqrt(x^2 + y^2).

intdiv

DECLARE NATIVE FUNCTION intdiv(x: Number,
y: Number): Number

Integer division with rounding toward zero.

ldexp

DECLARE NATIVE FUNCTION ldexp(x: Number,
exp: Number): Number

Multiplies a floating point value x by the number 10 raised to the exp power.

lgamma

DECLARE NATIVE FUNCTION lgamma(x: Number): Number

Log gamma function.

Reference

http://mathworld.wolfram.com/LogGammaFunction.html

log

DECLARE NATIVE FUNCTION log(x: Number): Number

Logarithm.

Reference

http://mathworld.wolfram.com/Logarithm.html

log10

DECLARE NATIVE FUNCTION log10(x: Number): Number

Logarithm (base 10).

Reference

http://mathworld.wolfram.com/Logarithm.html

log1p

DECLARE NATIVE FUNCTION log1p(x: Number): Number

Computes the natural (base e) logarithm of 1+arg.  This function is more precise than the expression log(1+arg) if arg is close to zero.

Reference

http://mathworld.wolfram.com/Logarithm.html

log2

DECLARE NATIVE FUNCTION log2(x: Number): Number

Logarithm (base 2).

Reference

http://mathworld.wolfram.com/Logarithm.html

max

DECLARE NATIVE FUNCTION max(a: Number,
b: Number): Number

Return the greater of two numbers.

Reference

http://mathworld.wolfram.com/Maximum.html

min

DECLARE NATIVE FUNCTION min(a: Number,
b: Number): Number

Return the lesser of two numbers.

Reference

http://mathworld.wolfram.com/Minimum.html

nearbyint

DECLARE NATIVE FUNCTION nearbyint(x: Number): Number

Returns an integer close to x by rounding.

odd

DECLARE NATIVE FUNCTION odd(x: Number): Boolean

Return TRUE if the given number is odd.

Reference

http://mathworld.wolfram.com/OddNumber.html

powmod

DECLARE NATIVE FUNCTION powmod( b,
 e,
m: Number): Number

Calculate modular exponentiation.

round

DECLARE NATIVE FUNCTION round(places: Number,
value: Number): Number

Round a number to a specified number of decimal places.

sign

DECLARE NATIVE FUNCTION sign(x: Number): Number

Returns -1 if x is negative, 0 if x is 0, or 1 if x is positive.

Reference

http://mathworld.wolfram.com/Sign.html

sin

DECLARE NATIVE FUNCTION sin(x: Number): Number

Sine.

Reference

http://mathworld.wolfram.com/Sine.html

sinh

DECLARE NATIVE FUNCTION sinh(x: Number): Number

Hyperbolic sine.

Reference

http://mathworld.wolfram.com/HyperbolicSine.html

sqrt

DECLARE NATIVE FUNCTION sqrt(x: Number): Number

Square root.

Reference

http://mathworld.wolfram.com/SquareRoot.html

tan

DECLARE NATIVE FUNCTION tan(x: Number): Number

Tangent.

Reference

http://mathworld.wolfram.com/Tangent.html

tanh

DECLARE NATIVE FUNCTION tanh(x: Number): Number

Hyperbolic tangent.

Reference

http://mathworld.wolfram.com/HyperbolicTangent.html

tgamma

DECLARE NATIVE FUNCTION tgamma(x: Number): Number

Gamma function.

Reference

http://mathworld.wolfram.com/GammaFunction.html

trunc

DECLARE NATIVE FUNCTION trunc(x: Number): Number

Truncate to integer (effectively, round toward zero).

Reference

http://mathworld.wolfram.com/Truncate.html

DECLARE NATIVE FUNCTION abs(x: Number): Number
Absolute value.
DECLARE NATIVE FUNCTION acos(x: Number): Number
Inverse cosine (arc cos).
DECLARE NATIVE FUNCTION acosh(x: Number): Number
Inverse hyperbolic cosine (arc cosh).
DECLARE NATIVE FUNCTION asin(x: Number): Number
Inverse sine (arc sin).
DECLARE NATIVE FUNCTION asinh(x: Number): Number
Inverse hyperbolic sine (arc sinh).
DECLARE NATIVE FUNCTION atan(x: Number): Number
Inverse tangent (arc tan).
DECLARE NATIVE FUNCTION atanh(x: Number): Number
Inverse hyperbolic tangent (arc tanh).
DECLARE NATIVE FUNCTION atan2( y,
x: Number): Number
Inverse tangent (arc tan) of y/x.
DECLARE NATIVE FUNCTION cbrt(x: Number): Number
Cube root.
DECLARE NATIVE FUNCTION ceil(x: Number): Number
Ceiling function.
DECLARE NATIVE FUNCTION cos(x: Number): Number
Cosine.
DECLARE NATIVE FUNCTION cosh(x: Number): Number
Hyperbolic cosine.
DECLARE NATIVE FUNCTION erf(x: Number): Number
Error function.
DECLARE NATIVE FUNCTION erfc(x: Number): Number
Complementary error function.
DECLARE NATIVE FUNCTION exp(x: Number): Number
Exponentiation.
DECLARE NATIVE FUNCTION exp2(x: Number): Number
Exponentiation (base 2).
DECLARE NATIVE FUNCTION expm1(x: Number): Number
Calculates exp(x)-1.0.
DECLARE NATIVE FUNCTION floor(x: Number): Number
Floor function.
DECLARE NATIVE FUNCTION frexp(x: Number,
OUT exp: Number): Number
Decomposes a floating point number into a normalised fraction and an integral power of 10.
DECLARE NATIVE FUNCTION hypot(x: Number,
y: Number): Number
Hypotenuse.
DECLARE NATIVE FUNCTION intdiv(x: Number,
y: Number): Number
Integer division with rounding toward zero.
DECLARE NATIVE FUNCTION ldexp(x: Number,
exp: Number): Number
Multiplies a floating point value x by the number 10 raised to the exp power.
DECLARE NATIVE FUNCTION lgamma(x: Number): Number
Log gamma function.
DECLARE NATIVE FUNCTION log(x: Number): Number
Logarithm.
DECLARE NATIVE FUNCTION log10(x: Number): Number
Logarithm (base 10).
DECLARE NATIVE FUNCTION log1p(x: Number): Number
Computes the natural (base e) logarithm of 1+arg.
DECLARE NATIVE FUNCTION log2(x: Number): Number
Logarithm (base 2).
DECLARE NATIVE FUNCTION max(a: Number,
b: Number): Number
Return the greater of two numbers.
DECLARE NATIVE FUNCTION min(a: Number,
b: Number): Number
Return the lesser of two numbers.
DECLARE NATIVE FUNCTION nearbyint(x: Number): Number
Returns an integer close to x by rounding.
DECLARE NATIVE FUNCTION odd(x: Number): Boolean
Return TRUE if the given number is odd.
DECLARE NATIVE FUNCTION powmod( b,
 e,
m: Number): Number
Calculate modular exponentiation.
DECLARE NATIVE FUNCTION round(places: Number,
value: Number): Number
Round a number to a specified number of decimal places.
DECLARE NATIVE FUNCTION sign(x: Number): Number
Returns -1 if x is negative, 0 if x is 0, or 1 if x is positive.
DECLARE NATIVE FUNCTION sin(x: Number): Number
Sine.
DECLARE NATIVE FUNCTION sinh(x: Number): Number
Hyperbolic sine.
DECLARE NATIVE FUNCTION sqrt(x: Number): Number
Square root.
DECLARE NATIVE FUNCTION tan(x: Number): Number
Tangent.
DECLARE NATIVE FUNCTION tanh(x: Number): Number
Hyperbolic tangent.
DECLARE NATIVE FUNCTION tgamma(x: Number): Number
Gamma function.
DECLARE NATIVE FUNCTION trunc(x: Number): Number
Truncate to integer (effectively, round toward zero).
Close