ADC Home > Reference Library > Reference > Mac OS X > Mac OS X Man Pages

 

This document is a Mac OS X manual page. Manual pages are a command-line technology for providing documentation. You can view these manual pages locally using the man(1) command. These manual pages come from many different sources, and thus, have a variety of writing styles.

For more information about the manual page format, see the manual page for manpages(5).



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 working with C99 floating point val-ues. values.
     ues.

     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 double extended precision.  On
     PowerPC Macs, the C type long double corresponds by default to ordinary double precision, but a 128-bit
     non-IEEE-754 long double type is also available via the compiler flag -mlong-double-128 and linker flag
     -lmx.

     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 single, double, and extended pre-cision; precision;
     cision; 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 preci-sion precision
     sion 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 cor-rectly correctly
     rectly 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 quotient.  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 expm1(double)

     exp(x), exp2(x), and expm1(x) return e**x, 2**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.

     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, respec-tively. respectively.
     tively.  atan2(y, x) returns the inverse tangent of y/x, 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, respectively.

     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(double)
     double y0(double)
     double y1(double)
     double yn(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 complementary error function evalu-ated evaluated
     ated at x, respectively.

MATHEMATICAL CONSTANTS
     In addition to the functions listed above, math.h defines a number of useful constants, listed below.
     All are defined as C99 floating-point constants.

     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 functions 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:1999(E) standard.

BSD                             March 20, 2007                             BSD

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.