EXP(3M)EXP(3M) NAME exp, expm1, exp2, log, log10, log2, log1p, pow, expf, expm1f, exp2f, logf, log10f, log2f, log1pf, powf, expl, expm1l, exp2l, logl, log2l, log10l, log1pl, powl, cexp, clog, cpow, cexpf, clogf, cpowf, cexpl, clogl, cpowl - Exponential, logarithm, power SYNOPSIS #include <math.h> double exp(double x); float expf(float x); long double expl(long double x); double expm1(double x); float expm1f(float x); long double expm1l(long double x); double exp2(double x); float exp2f(float x); long double exp2l(long double x); double log(double x); float logf(float x); long double logl(long double x); double log2(double x); float log2f(float x); long double log2l(long double x); double log10(double x); float log10f(float x); long double log10l(long double x); double log1p(double x); float log1pf(float x); long double log1pl(long double x); double pow(double x, double y); float powf(float x, float y); long double powl(long double x, long double y); #include <complex.h> double complex cexp(double complex z); float complex cexpf(float complex z); long double complex cexpl(long double complex z); double complex clog(double complex x); float complex clogf(float complex x); long double complex clogl(long double complex x); double complex cpow(double complex x, double complex y); float complex cpowf(float complex x, float complex y); long double complex cpowl(long double complex x, long double complex y); DESCRIPTION Long double and complex valued routines listed above are only available in the standard math library libm.a, and in libmx.a. The exp2 and log2 routines are not available for programs compiled with the O32 ABI. Alternate entries exist for several routines. The following lists these routines and the ANSI standard name and the alternate entry name: ANSI standard name Alternate name expf fexp expm1f fexpm1 logf flog log10f flog10f log1pf flog10 expl qexp expm1l qexpm1 logl qlog log10l qlog10 log1pl qlog1p powl qpow The exp family return the exponential function of x, e**x. The expm1 family return exp(x)-1 accurately even for tiny x. The exp2 functions computer the base-2 exponential of x 2**x. The cexp functions return the complex base-e exponential value. The log functions return the natural logarithm of x. The log2 functions return log(2)x. The log10 functions return the base 10 logarithm of x. The log1p family return log(1+x) accurately even for tiny x. The clog functions return the complex natural logarithm value, in the range of a strip mathetmatically unbounded along the real axis and in the interval [-iPI, +iPI] along the imaginary axis. pow(x,y), its single-precision counterpart powf(x,y), and its long double counterpart powl(x,y), return x**y. cpow functions return the complex power function value. NOTES Long double operations on this system are only supported in round to nearest rounding mode (the default). The system must be in round to nearest rounding mode when calling any of the long double functions, or incorrect answers will result. Users concerned with portability to other computer systems should note that the long double and float versions of these functions were optional according to the ANSI C Programming Language Specification ISO/IEC 9899 : 1990 (E) and are no longer optional according to ISO/IEC 9899:1999(E). Long double functions have been renamed to be compliant with the ANSI-C standard, however to be backward compatible, they may still be called with the double precision function name prefixed with a q. pow(x,0) returns x**0 = 1 for all x including x = 0 and Infinity. Previous implementations of pow defined Nan**0 to be 1 as well, but this behavior has been changed to conform to the IEEE standard. x**0 = 1 is returned in all other cases for the following reasons: 1. Any program that already tests if x is zero (or infinite) before computing x**0 cannot care if 0**0 = 1 or not. Any program that depends upon 0**0 to be invalid is dubious anyway because that expression's meaning and (if invalid) its consequences vary from one computer system to another. 3. Some Algebra texts (e.g. Sigler's) define x**0 = 1 for all x, including x = 0. This is compatible with the convention that accepts a[0] as the value of the following polynomial: p(x) = a[0]*x**0 + a[1]*x**1 + a[2]*x**2 +...+ a[n]*x**n at x = 0 rather than reject a[0]*0**0 as invalid. 1. Analysts will accept 0**0 = 1 despite that x**y can approach anything or nothing as x and y approach 0 independently. The reason for setting 0**0 = 1 is because if x(z) and y(z) are any functions analytic (expandable in power series) in z around z = 0, and if there x(0) = y(0) = 0, then x(z)**y(z) -> 1 as z -> 0. 2. If 0**0 = 1, then infinity**0 = 1/0**0 = 1 too; and because x**0 = 1 for all finite and infinite non-NaN x. Errors and log10(x) and pow(x,y) to within about 2 ULPs; a ULP one Unit in the Last Place. Moderate values of pow are accurate enough that pow(integer,integer) is exact until it is bigger than 2**53 for double. RETURN VALUES Functions in the standard math library, libm.a, are referred to as -lm versions. Those in math library libmx.a are referred to as -lmx versions. Those in the the BSD math library, libm43.a, are referred to as -lm43 versions. When NaN is used as an argument, a NaN is returned. The -lm and -lmx versions always return the default Quiet NaN and set errno to EDOM. The -lm43 versions never set errno. The value of HUGE_VAL is IEEE Infinity. The exp functions return HUGE_VAL when the correct value would overflow, and return zero if the correct value would underflow. The -lm and -lmx versions set the value of errno to ERANGE for both underflow and overflow. The log functions return NaN when x is less than zero, indicating an invalid operation. The -lm and -lmx versions also set errno to EDOM. When x is zero, the log functions return -HUGE_VAL. The -lm and -lmx versions set errno to ERANGE. The pow functions return NaN indicating an invalid operation, if x is negative and y is not an integer. The -lm and -lmx versions also set errno to EDOM. When x is zero and y is negative, the -lm and -lmx versions return HUGE_VAL and set errno to EDOM. The -lm43 versions return HUGE_VAL. When both arguments are zero, the pow functions return one. When the correct value for pow would overflow or underflow, the pow functions return +/-HUGE_VAL or zero, respectively. The -lm and -lmx versions set errno to ERANGE. See matherr(3M) for a description of error handling for -lmx functions. SEE ALSO math(3M), matherr(3M)