Last update Fri Apr 28 11:05:24 2006
std
 std.array
 std.atomic
 std.bitarray
 std.exception
 std.intrinsic
 std.memory
 std.regexp
 std.thread
 std.traits
 std.unicode
 std.vararg
 std.math.core
 std.math.ieee
 std.math.special

std.math.core



const real E;
e

const real LOG2T;
log210

const real LOG2E;
log2e

const real LOG2;
log102

const real LOG10E;
log10e

const real LN2;
ln 2

const real LN10;
ln 10

const real PI;
π

const real PI_2;
π / 2

const real PI_4;
π / 4

const real M_1_PI;
1 / π

const real M_2_PI;
2 / π

const real M_2_SQRTPI;
2 / √π

const real SQRT2;
√2

const real SQRT1_2;
√½

real abs(real x);
long abs(long x);
int abs(int x);
real abs(creal z);
real abs(ireal y);
Calculates the absolute value

For complex numbers, abs(z) = sqrt( + ) = hypot(z.re, z.im).

creal conj(creal z);
ireal conj(ireal y);
Complex conjugate

conj(x + iy) = x - iy

Note that z * conj(z) = - is always a real number

real cos(real x);
Returns cosine of x. x is in radians.



BUGS:
Results are undefined if |x| >= .

real sin(real x);
Returns sine of x. x is in radians.



BUGS:
Results are undefined if |x| >= .

real tan(real x);
Returns tangent of x. x is in radians.



real acos(real x);
Calculates the arc cosine of x, returning a value ranging from -π/2 to π/2.



real asin(real x);
Calculates the arc sine of x, returning a value ranging from -π/2 to π/2.



real atan(real x);
Calculates the arc tangent of x, returning a value ranging from -π/2 to π/2.



real atan2(real x, real y);
Calculates the arc tangent of y / x, returning a value ranging from -π/2 to π/2.



real cosh(real x);
Calculates the hyperbolic cosine of x.



real sinh(real x);
Calculates the hyperbolic sine of x.



real tanh(real x);
Calculates the hyperbolic tangent of x.



real acosh(real x);
Calculates the inverse hyperbolic cosine of x.

Mathematically, acosh(x) = log(x + sqrt( x*x - 1))



real asinh(real x);
Calculates the inverse hyperbolic sine of x.

Mathematically,
  asinh(x) =  log( x + sqrt( x*x + 1 )) // if x >= +0
  asinh(x) = -log(-x + sqrt( x*x + 1 )) // if x <= -0


real atanh(real x);
Calculates the inverse hyperbolic tangent of x, returning a value from ranging from -1 to 1.

Mathematically, atanh(x) = log( (1+x)/(1-x) ) / 2





float sqrt(float x);
double sqrt(double x);
real sqrt(real x);
creal sqrt(creal z);
Compute square root of x.



real cbrt(real x);
Calculates the cube root x.



real exp(real x);
Calculates e.



real expm1(real x);
Calculates the value of the natural logarithm base (e) raised to the power of x, minus 1.

For very small x, expm1(x) is more accurate than exp(x)-1.



real exp2(real x);
Calculates 2.



real log(real x);
Calculate the natural logarithm of x.



real log1p(real x);
Calculates the natural logarithm of 1 + x.

For very small x, log1p(x) will be more accurate than log(1 + x).



real log2(real x);
Calculates the base-2 logarithm of x: log2x



real log10(real x);
Calculate the base-10 logarithm of x.



real pow(real x, uint n);
real pow(real x, int n);
Fast integral powers.

real pow(real x, real y);
Calculates x.



real hypot(real x, real y);
Calculates the length of the hypotenuse of a right-angled triangle with sides of length x and y. The hypotenuse is the value of the square root of the sums of the squares of x and y:

sqrt(x² + y²)

Note that hypot(x, y), hypot(y, x) and hypot(x, -y) are equivalent.



real poly(real x, real[] A);
Evaluate polynomial A(x) = a0 + a1x + a2x² + a3x³ ...

Uses Horner's rule A(x) = a0 + x(a1 + x(a2 + x(a3 + ...)))

Params:
real[] A array of coefficients a0, a1, etc.

real floor(real x);
Returns the value of x rounded downward to the next integer (toward negative infinity).

real ceil(real x);
Returns the value of x rounded upward to the next integer (toward positive infinity).

real round(real x);
Return the value of x rounded to the nearest integer. If the fractional part of x is exactly 0.5, the return value is rounded to the even integer.

real trunc(real x);
Returns the integer portion of x, dropping the fractional portion.

This is also known as "chop" rounding.

int rndint(real x);
long rndlong(real x);
Rounds x to the nearest int or long.

This is generally the fastest method to convert a floating-point number to an integer. Note that the results from this function depend on the rounding mode, if the fractional part of x is exactly 0.5. If using the default rounding mode (ties round to even integers) rndint(4.5) == 4, rndint(5.5)==6.