cc [flag . . .] file . . . -lm [library . . .]#include <math.h>
double exp(double x);
float expf(float x);
double expm1(double x);
double cbrt(double x);
double log(double x);
float logf(float x);
double log10(double x);
float log10f(float x);
double log1p(double x);
double pow(double x, double y);
float powf(float x, float y);
double sqrt(double x);
float sqrtf(float x);
expm1 returns e^x-1.0.
cbrt returns the cube root of x.
log and logf return the natural logarithm of x. The value of x must be positive.
log10 and log10f return the base ten logarithm of x. The value of x must be positive.
log1p returns the natural logarithm of 1.0+x. The value of x must be greater than -1.0.
pow and powf return x^y. If x is zero, y must be non-negative. If x is negative, y must be an integer.
sqrt and sqrtf return the non-negative square root of x. The value of x may not be negative.
expm1 returns a value that will compare equal to HUGE_VAL when the correct value would overflow and set errno to ERANGE. expm1 returns + infinity if x has the value + infinity. expm1 returns -1.0 if x has the value - infinity. expm1 returns NaN and sets errno to EDOM if x has the value NaN.
log, logf, log10, and log10f return a value that will compare equal to -HUGE_VAL and set errno to ERANGE when x is zero. On systems that support IEEE floating-point, the divide by zero exception is raised.
If x is negative, log, logf, log10, and log10f return IEEE NaN on systems that support it and raise the invalid operation exception. Otherwise, they return zero and set errno to EDOM.
log1p returns -HUGE_VAL and sets errno to ERANGE if x has the value -1.0. log1p returns -HUGE_VAL or NaN and sets errno to EDOM if x is less than -1.0. log1p returns NaN and sets errno to EDOM if x has the value NaN.
On systems that support IEEE NaN, if any of the inputs to each of these functions is a quiet NaN, that value is returned. If any input is a signaling NaN, a quiet NaN is returned and the invalid operation exception is raised. In either case, errno is set to EDOM. The only exceptions to this rule are for pow and powf, which always return 1 when their second argument is zero, regardless of the value of their first argument.
If x is negative and y is finite and nonintegral, pow and powf return IEEE NaN on systems that support it and raise the invalid operation exception. Otherwise, they return zero and set errno to EDOM.
When x is zero and y is negative, finite and an odd integer, pow and powf return a value that will compare equal to ±HUGE_VAL, according to the sign of x, (+HUGE_VAL, if -0 is not supported). When x is zero and y is negative, finite and not an odd integer, pow and powf return a value that will compare equal to +HUGE_VAL. In each of these cases, errno is set to EDOM. On systems that support IEEE exceptions, the divide by zero exception is raised.
On systems that support IEEE infinity, when x is ±1 and y is ± infinity, pow and powf return IEEE NaN, raise the invalid operation exception and set errno to EDOM.
When the correct value for pow or powf would overflow or underflow, these functions return a value that will compare equal to ±HUGE_VAL or zero, respectively, and set errno to ERANGE.
When x is negative, sqrt and sqrtf return IEEE NaN on systems that support it and raise the invalid operation exception. Otherwise, they return 0. errno is set to EDOM.
If the program was compiled with the -Xt compilation mode, a value that will compare equal to ±HUGE is returned instead of ±HUGE_VAL. log, logf, log10, and log10f return a value that will compare equal to -HUGE for non-positive arguments and set errno to EDOM. In addition, a message indicating DOMAIN error is printed on the standard error output. pow and powf return zero and set errno to EDOM when x is 0 and y is non-positive, or when x is negative and y is non-integral. In addition, a message indicating DOMAIN error is printed on the standard error output. sqrt and sqrtf return zero and set errno to EDOM when x is negative. In addition, a message indicating DOMAIN error is printed on the standard error output. These error handling procedures may be changed with the function matherr.