manpagez: man pages & more
man math(3)
Home | html | info | man
math(3)                  BSD Library Functions Manual                  math(3)


NAME

     math -- mathematical library functions


SYNOPSIS

     #include <math.h>


DESCRIPTION

     The header file math.h provides function prototypes and macros for work-
     ing with floating point values.

     Each math.h function is provided in three variants: single, double and
     extended precision.  The single and double precision variants operate on
     IEEE-754 single and double precision values, which correspond to the C
     types float and double, respectively.

     On Intel Macs, the C type long double corresponds to 80-bit IEEE-754 dou-
     ble extended precision.  On iOS devices using ARM processors, long double
     is mapped to double, as there is no hardware-supported wider type.

     Details of the floating point formats can be found via "man float".

     Users who need to repeatedly perform the same calculation on a large set
     of data will probably find that the vector math library (composed of
     vMathLib and vForce) yields better performance for their needs than
     sequential calls to the libm.

     Users who need to perform mathematical operations on complex floating-
     point numbers should consult the man pages for the complex portion of the
     math library, via "man complex".


LIST OF FUNCTIONS

     Each of the functions that use floating-point values are provided in sin-
     gle, double, and extended precision; the double precision prototypes are
     listed here.  The man pages for the individual functions provide more
     details on their use, special cases, and prototypes for their single and
     extended precision versions.

     int fpclassify(double)
     int isfinite(double)
     int isinf(double)
     int isnan(double)
     int isnormal(double)
     int signbit(double)

     These function-like macros are used to classify a single floating-point
     argument.

     double copysign(double, double)
     double nextafter(double, double)

     copysign(x, y) returns the value equal in magnitude to x with the sign of
     y.  nextafter(x, y) returns the next floating-point number after x in the
     direction of y.  Both are correctly-rounded.

     double nan(const char *tag)

     The nan() function returns a quiet NaN, without raising the invalid flag.

     double ceil(double)
     double floor(double)
     double nearbyint(double)
     double rint(double)
     double round(double)
     long int lrint(double)
     long int lround(double)
     long long int llrint(double)
     long long int llround(double)
     double trunc(double)

     These functions provide various means to round floating-point values to
     integral values.  They are correctly rounded.

     double fmod(double, double)
     double remainder(double, double)
     double remquo(double x, double y, int *)

     These return a remainder of the division of x by y with an integral quo-
     tient.  remquo() additionally provides access to a few lower bits of the
     quotient.  They are correctly rounded.

     double fdim(double, double)
     double fmax(double, double)
     double fmin(double, double)

     fmax(x, y) and fmin(x, y) return the maximum and minimum of x and y,
     respectively.  fdim(x, y) returns the positive difference of x and y. All
     are correctly rounded.

     double fma(double x, double y, double z)

     fma(x, y, z) computes the value (x*y) + z as though without intermediate
     rounding.  It is correctly rounded.

     double fabs(double)
     double sqrt(double)
     double cbrt(double)
     double hypot(double, double)

     fabs(x), sqrt(x), and cbrt(x) return the absolute value, square root, and
     cube root of x, respectively.  hypot(x, y) returns sqrt(x*x + y*y).
     fabs() and sqrt() are correctly rounded.

     double exp(double)
     double exp2(double)
     double __exp10(double)
     double expm1(double)

     exp(x), exp2(x), __exp10(x), and expm1(x) return e**x, 2**x, 10**x, and
     e**x - 1, respectively.

     double log(double)
     double log2(double)
     double log10(double)
     double log1p(double)

     log(x), log2(x), and log10(x) return the natural, base-2, and base-10
     logarithms of x, respectively.  log1p(x) returns the natural log of 1+x.

     double logb(double)
     int ilogb(double)

     logb(x) and ilogb(x) return the exponent of x.

     double modf(double, double *)
     double frexp(double, int *)

     modf(x, &y) returns the fractional part of x and stores the integral part
     in y.  frexp(x, &n) returns the mantissa of x and stores the exponent in
     n. They are correctly rounded.

     double ldexp(double, int)
     double scalbn(double, int)
     double scalbln(double, long int)

     ldexp(x, n), scalbn(x, n), and scalbln(x, n) return x*2**n.  They are
     correctly rounded.

     double pow(double, double)

     pow(x,y) returns x raised to the power y.

     double cos(double)
     double sin(double)
     double tan(double)

     cos(x), sin(x), and tan(x) return the cosine, sine and tangent of x,
     respectively.  Note that x is interpreted as specifying an angle in radi-
     ans.

     double cosh(double)
     double sinh(double)
     double tanh(double)

     cosh(x), sinh(x), and tanh(x) return the hyperbolic cosine, hyperbolic
     sine and hyperbolic tangent of x, respectively.

     double acos(double)
     double asin(double)
     double atan(double)
     double atan2(double, double)

     acos(x), asin(x), and atan(x) return the inverse cosine, inverse sine and
     inverse tangent of x, respectively.  Note that the result is an angle in
     radians.  atan2(y, x) returns the inverse tangent of y/x in radians, with
     sign chosen according to the quadrant of (x,y).

     double acosh(double)
     double asinh(double)
     double atanh(double)

     acosh(x), asinh(x), and atanh(x) return the inverse hyperbolic cosine,
     inverse hyperbolic sine and inverse hyperbolic tangent of x, respec-
     tively.

     double tgamma(double)
     double lgamma(double)

     tgamma(x) and lgamma(x) return the values of the gamma function and its
     logarithm evalutated at x, respectively.

     double j0(double)
     double j1(double)
     double jn(int, double)
     double y0(double)
     double y1(double)
     double yn(int, double)

     j0(x), j1(x), and jn(x) return the values of the zeroth, first, and nth
     Bessel function of the first kind evaluated at x, respectively.  y0(x),
     y1(x), and yn(x) return the values of the zeroth, first, and nth Bessel
     function of the second kind evaluated at x, respectively.

     double erf(double)
     double erfc(double)

     erf(x) and erfc(x) return the values of the error function and the com-
     plementary error function evaluated at x, respectively.


MATHEMATICAL CONSTANTS

     In addition to the functions listed above, math.h defines a number of
     useful constants, listed below.

     CONSTANT        VALUE
     M_E             base of natural logarithm, e
     M_LOG2E         log2(e)
     M_LOG10E        log10(e)
     M_LN2           ln(2)
     M_LN10          ln(10)
     M_PI            pi
     M_PI_2          pi / 2
     M_PI_4          pi / 4
     M_1_PI          1 / pi
     M_2_PI          2 / pi
     M_2_SQRTPI      2 / sqrt(pi)
     M_SQRT2         sqrt(2)
     M_SQRT1_2       sqrt(1/2)


IEEE STANDARD 754 FLOATING-POINT ARITHMETIC

     The libm functions declared in math.h provide mathematical library func-
     tions in single-, double-, and extended-precision IEEE-754 floating-point
     formats on Intel macs, and in single- and double-precision IEEE-754
     floating-point formats on PowerPC macs.


SEE ALSO

     float(3), complex(3)


STANDARDS

     The <math.h> functions conform to the ISO/IEC 9899:2011 standard.

BSD                             August 16, 2012                            BSD

Mac OS X 10.9.1 - Generated Wed Jan 8 19:39:06 CST 2014
© manpagez.com 2000-2024
Individual documents may contain additional copyright information.