The math library provides some mathematical functions, which may be called from Cind programs.

To connect math library use syntax of getting linked libraries, with "math" word as the second argument:

var lmath = @("lib","math");

Functions

List of functions available from the math library:

 function args type of arguments type of result description sin 1 float float sine function cos 1 float float cosine function tan 1 float float tangent function asin 1 float float arc sine function acos 1 float float arc cosine function atan 1 float float arc tangent function atan2 2 (float y,float x) float arc tangent function of y/x sinh 1 float float hyperbolic sine function cosh 1 float float hyperbolic cosine function tanh 1 float float hyperbolic tangent function asinh 1 float float inverse hyperbolic sine function acosh 1 float float inverse hyperbolic cosine function atanh 1 float float inverse hyperbolic tangent function exp 1 float float base-e exponential function exp2 1 float float base-2 exponential function expm1 1 float float base-e exponential function minus 1 pow 2 (float x,float y) float power function, returns xy log 1 float float natural logarithmic function log1p 1 float float natural logarithm of 1 plus argument log10 1 float float base-10 logarithmic function log2 1 float float base-2 logarithmic function sqrt 1 float float square root function hypot 2 (float x,float y) float length of the hypotenuse of a right-angled triangle with sides of length x and y ldexp 2 (float x,int exp) float multiply float number by integral power of 2 fabs 1 float float absolute value of float number floor 1 float float largest integral value not greater than argument ceil 1 float float smallest integral value not less than argument round 1 float float round to nearest integer trunc 1 float float round to integer, toward zero fmod 2 (float x,float y) float floating-point remainder function remainder 2 (float x,float y) float another floating-point remainder function tgamma 1 float float the Gamma function lgamma 1 float float natural logarithm of the absolute valueof the Gamma function

Remarks:

• When the argument is outside the expected range (for example, outside [-1,1] for the asin and acos functions), then float NaN, float INFINITY or float NEGINFINITY value will be returned.
• The hyperbolic sine function is defined as:
sinh(x) = (exp(x) - exp(-x)) / 2.
• The hyperbolic cosine function is defined as:
cosh(x) = (exp(x) + exp(-x)) / 2.
• The expm1 function returns
expm1(x) = exp(x) - 1,
this function is useful to increase accuracy around value 1.
• The log1p function returns
log1p(x) = log(1+x).
• The hypot function returns: hypot(x,y) = sqrt(x2 + y2),
which is also an euclidean distance of the point (x,y) from the origin.
• The ldexp function returns: ldexp(x,exp) = x * (2exp).
• Floor function works that: floor(0.5) is 0.0, and floor(-0.5) is -1.0.
• Ceil function works that: ceil(0.5) is 1.0, and ceil(-0.5) is 0.0.
• Round function works that: round(0.5) is 1.0, and round(-0.5) is -1.0.
• The fmod function computes the floating-point remainder of dividing x by y.
The return value is x-n*y, where n is the quotient of x/y, rounded toward zero to an integer.
• The remainder function computes the remainder of dividing x by y.
The return value is x-n*y, where n is the value x/y, rounded to the nearest integer.
If the absolute value of x-n*y is 0.5, then n is chosen to be even.
• The Gamma function is defined as:
tgamma(x) = integral from 0 to infinity of t^(x-1) e^-t dt.

Example of usage

var lmath = @("lib","math"); float x = 0.25f; host.println("sin("+x+") = "+ lmath.sin(x) );

 Cind programming language 1.0.4