EXP(3M)
NAME
exp, log, log10, pow, sqrt − exponential, logarithm, power, square root functions
NOTICE
This entry is not identical to the corresponding entry in the HP-UX Reference. It was modified after the manual went to print to conform to the XPG3 Standard. Change bars in the right-hand margin show additions and changes. An asterisk in the right margin indicates deleted text.
SYNOPSIS
#include <math.h>
double exp (x)
double x;
double log (x)
double x;
double log10 (x)
double x;
double pow (x, y)
double x, y;
double sqrt (x)
double x;
DESCRIPTION
Exp returns ex.
Log returns the natural logarithm of x. The value of x must be positive.
Log10 returns the logarithm base ten of x. The value of x must be positive.
Pow returns xy. If x is 0.0, y must be positive. If x is negative, y must be an integer.
Sqrt returns the non-negative square root of x. The value of x must not be negative.
DEPENDENCIES
Series 300
The algorithms used are those from HP 9000 BASIC.
Series 800 (/lib/libm.a)
Exp returns:
• +INFINITY when x is +INFINITY ,
• 0.0 when x is −INFINITY .
Log and log10 return +INFINITY when x is +INFINITY .
Pow returns +INFINITY when:
• Absolute value of x is greater than 1.0 and y is +INFINITY ,
• Absolute value of x is less than 1.0 and y is −INFINITY ,
• x is +INFINITY and y is greater than 0.0, or
• x is −INFINITY and y is an even integer.
Pow returns −INFINITY when x is −INFINITY and y is an odd integer.
Pow returns 0.0 when:
• Absolute value of x is greater than 1.0 and y is −INFINITY ,
• absolute value of x is less than 1.0 and y is +INFINITY ,
• x is +INFINITY and y is less than 0.0.
Sqrt returns +INFINITY when x is +INFINITY .
Series 800 (ANSI C /lib/libM.a)
Exp returns:
• +INFINITY when x is +INFINITY ,
• 0.0 when x is −INFINITY .
Log and log10 return +INFINITY when x is +INFINITY .
Pow returns 1.0 when x and y are both 0.0.
Pow returns +INFINITY when:
• Absolute value of x is greater than 1.0 and y is +INFINITY ,
• Absolute value of x is less than 1.0 and y is −INFINITY ,
• x is +INFINITY and y is greater than 0.0, or
• x is −INFINITY and y is an even integer.
Pow returns −INFINITY when x is −INFINITY and y is an odd integer.
Pow returns 0.0 when:
• Absolute value of x is greater than 1.0 and y is −INFINITY ,
• absolute value of x is less than 1.0 and y is +INFINITY ,
• x is +INFINITY and y is less than 0.0.
Sqrt returns +INFINITY when x is +INFINITY .
ERRORS
Series 300
Exp returns HUGE_VAL when the correct value would overflow, or 0.0 when the correct value would underflow, and sets errno to ERANGE.
Log and log10 return −HUGE_VAL and set errno to EDOM when x is non-positive. A message indicating DOMAIN error (or SING error when x is 0.0) is printed on the standard error output.
Pow returns 0.0 and sets errno to EDOM when x is 0.0 and y is non-positive, or when x is negative and y is not an integer. In these cases a message indicating DOMAIN error is printed on the standard error output. When the correct value for pow would overflow or underflow, pow returns ±HUGE_VAL or 0.0 respectively, and sets errno to ERANGE.
Sqrt returns 0.0 and sets errno to EDOM when x is negative. A message indicating DOMAIN error is printed on the standard error output.
Series 800 (/lib/libm.a)
Exp returns HUGE_VAL when the correct value would overflow, or 0.0 when the correct value would underflow, and sets errno to ERANGE. NaN is returned and errno is set to EDOM when x is NaN. Log and log10 return −HUGE_VAL and set errno to EDOM when x is non-positive. NaN is returned and errno is set to EDOM when x is NaN or −INFINITY . A message indicating DOMAIN error (or SING error when x is 0.0) is printed on the standard error output in these cases.
Pow returns 0.0 and sets errno to EDOM when x is 0.0 and y is negative, or when x is negative and y is not an integer. NaN is returned and errno is set to EDOM when x or y is NaN. In these cases a message indicating DOMAIN error is printed on the standard error output. When the correct value for pow would overflow or underflow, pow returns ±HUGE_VAL or 0.0 respectively, and sets errno to ERANGE.
Sqrt returns NaN and sets errno to EDOM when x is negative, NaN or −INFINITY . A message indicating DOMAIN error is printed on the standard error output.
Series 800 (ANSI C /lib/libM.a)
No error messages are printed on the standard error output.
Exp returns HUGE_VAL when the correct value would overflow, or 0.0 when the correct value would underflow, and sets errno to ERANGE . NaN is returned and errno is set to EDOM when x is NaN.
Log and log10 return NaN and set errno to EDOM when x is negative, −INFINITY, or NaN. −HUGE_VAL is returned and errno is set to EDOM when x is 0.0.
Pow returns −HUGE_VAL and sets errno to EDOM when x is 0.0 and y is negative. NaN is returned and errno is set to EDOM when x is negative and y is not an integer or when x or y is NaN. When the correct value for pow would overflow or underflow, pow returns ±HUGE_VAL or 0.0 respectively, and sets errno to ERANGE .
Sqrt returns NaN and sets errno to EDOM when x is negative, NaN or −INFINITY .
These error-handling procedures may be changed with the function matherr(3M).
SEE ALSO
hypot(3M), isinf(3M), isnan(3M), matherr(3M), sinh(3M).
STANDARDS CONFORMANCE
exp: SVID2, XPG2, XPG3, POSIX.1, FIPS 151-1, ANSI C
log: SVID2, XPG2, XPG3, POSIX.1, FIPS 151-1, ANSI C
log10: SVID2, XPG2, XPG3, POSIX.1, FIPS 151-1, ANSI C
pow: SVID2, XPG2, XPG3, POSIX.1, FIPS 151-1, ANSI C
sqrt: SVID2, XPG2, XPG3, POSIX.1, FIPS 151-1, ANSI C
Hewlett-Packard Company — HP-UX 7.0 (Revised)