|
|
1.1 root 1: .\" Copyright (c) 1985 Regents of the University of California.
2: .\" All rights reserved. The Berkeley software License Agreement
3: .\" specifies the terms and conditions for redistribution.
4: .\"
5: .\" @(#)exp.3 6.9 (Berkeley) 5/27/86
6: .\"
7: .TH EXP 3M "May 27, 1986"
8: .UC 4
9: .ds nn \fINaN\fR
10: .ds up \fIulp\fR
11: .SH NAME
12: exp, expm1, log, log10, log1p, pow \- exponential, logarithm, power
13: .SH SYNOPSIS
14: .nf
15: .B #include <math.h>
16: .PP
17: .B double exp(x)
18: .B double x;
19: .PP
20: .B double expm1(x)
21: .B double x;
22: .PP
23: .B double log(x)
24: .B double x;
25: .PP
26: .B double log10(x)
27: .B double x;
28: .PP
29: .B double log1p(x)
30: .B double x;
31: .PP
32: .B double pow(x,y)
33: .B double x,y;
34: .fi
35: .SH DESCRIPTION
36: .PP
37: Exp returns the exponential function of x.
38: .PP
39: Expm1 returns exp(x)\-1 accurately even for tiny x.
40: .PP
41: Log returns the natural logarithm of x.
42: .PP
43: Log10 returns the logarithm of x to base 10.
44: .PP
45: Log1p returns log(1+x) accurately even for tiny x.
46: .PP
47: Pow(x,y) returns
48: .if n \
49: x**y.
50: .if t \
51: x\u\s8y\s10\d.
52: .SH ERROR (due to Roundoff etc.)
53: exp(x), log(x), expm1(x) and log1p(x) are accurate to within
54: an \*(up, and log10(x) to within about 2 \*(ups;
55: an \*(up is one \fIU\fRnit in the \fIL\fRast \fIP\fRlace.
56: The error in pow(x,y) is below about 2 \*(ups when its
57: magnitude is moderate, but increases as pow(x,y) approaches
58: the over/underflow thresholds until almost as many bits could be
59: lost as are occupied by the floating\-point format's exponent
60: field; that is 8 bits for VAX D and 11 bits for IEEE 754 Double.
61: No such drastic loss has been exposed by testing; the worst
62: errors observed have been below 20 \*(ups for VAX D,
63: 300 \*(ups for IEEE 754 Double.
64: Moderate values of pow are accurate enough that pow(integer,integer)
65: is exact until it is bigger than 2**56 on a VAX, 2**53 for IEEE 754.
66: .SH DIAGNOSTICS
67: Exp, expm1 and pow return the reserved operand on a VAX when the correct
68: value would overflow, and they set \fIerrno\fR to ERANGE.
69: Pow(x,y) returns the reserved operand on a VAX and sets \fIerrno\fR
70: to EDOM when x < 0 and y is not an integer.
71: .PP
72: On a VAX, \fIerrno\fR is set to EDOM and the reserved operand is returned
73: by log unless x > 0, by log1p unless x > \-1.
74: .SH NOTES
75: The functions exp(x)\-1 and log(1+x) are called expm1
76: and logp1 in BASIC on the Hewlett\-Packard HP\-71B and APPLE
77: Macintosh, EXP1 and LN1 in Pascal, exp1 and log1 in C
78: on APPLE Macintoshes, where they have been provided to make
79: sure financial calculations of ((1+x)**n\-1)/x, namely
80: expm1(n\(**log1p(x))/x, will be accurate when x is tiny.
81: They also provide accurate inverse hyperbolic functions.
82: .PP
83: Pow(x,0) returns x**0 = 1 for all x including x = 0,
84: .if n \
85: Infinity
86: .if t \
87: \(if
88: (not found on a VAX), and \*(nn (the reserved
89: operand on a VAX). Previous implementations of pow may
90: have defined x**0 to be undefined in some or all of these
91: cases. Here are reasons for returning x**0 = 1 always:
92: .IP (1) \w'\0\0\0\0'u
93: Any program that already tests whether x is zero (or
94: infinite or \*(nn) before computing x**0 cannot care
95: whether 0**0 = 1 or not. Any program that depends
96: upon 0**0 to be invalid is dubious anyway since that
97: expression's meaning and, if invalid, its consequences
98: vary from one computer system to another.
99: .IP (2) \w'\0\0\0\0'u
100: Some Algebra texts (e.g. Sigler's) define x**0 = 1 for
101: all x, including x = 0.
102: This is compatible with the convention that accepts a[0]
103: as the value of polynomial
104: .ce
105: p(x) = a[0]\(**x**0 + a[1]\(**x**1 + a[2]\(**x**2 +...+ a[n]\(**x**n
106: .IP
107: at x = 0 rather than reject a[0]\(**0**0 as invalid.
108: .IP (3) \w'\0\0\0\0'u
109: Analysts will accept 0**0 = 1 despite that x**y can
110: approach anything or nothing as x and y approach 0
111: independently.
112: The reason for setting 0**0 = 1 anyway is this:
113: .IP
114: If x(z) and y(z) are \fIany\fR functions analytic (expandable
115: in power series) in z around z = 0, and if there
116: x(0) = y(0) = 0, then x(z)**y(z) \(-> 1 as z \(-> 0.
117: .IP (4) \w'\0\0\0\0'u
118: If 0**0 = 1, then
119: .if n \
120: infinity**0 = 1/0**0 = 1 too; and
121: .if t \
122: \(if**0 = 1/0**0 = 1 too; and
123: then \*(nn**0 = 1 too because x**0 = 1 for all finite
124: and infinite x, i.e., independently of x.
125: .SH SEE ALSO
126: math(3M), infnan(3M)
127: .SH AUTHOR
128: Kwok\-Choi Ng, W. Kahan
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.