3a0ae493b65f604ea84b73a9ae8ab9c1eb35b0b7
[dragonfly.git] / lib / libm / man / log.3
1 .\" $NetBSD: log.3,v 1.3 2011/09/13 08:51:32 wiz Exp $
2 .\"
3 .\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi>
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 .\" POSSIBILITY OF SUCH DAMAGE.
26 .\"
27 .Dd September 13, 2011
28 .Dt LOG 3
29 .Os
30 .Sh NAME
31 .Nm log ,
32 .Nm logf ,
33 .Nm log10 ,
34 .Nm log10f ,
35 .Nm log1p ,
36 .Nm log1pf
37 .Nm log2 ,
38 .Nm log2f ,
39 .Nd logarithm functions
40 .Sh LIBRARY
41 .Lb libm
42 .Sh SYNOPSIS
43 .In math.h
44 .Ft double
45 .Fn log "double x"
46 .Ft float
47 .Fn logf "float x"
48 .Ft double
49 .Fn log10 "double x"
50 .Ft float
51 .Fn log10f "float x"
52 .Ft double
53 .Fn log1p "double x"
54 .Ft float
55 .Fn log1pf "float x"
56 .Ft double
57 .Fn log2 "double x"
58 .Ft float
59 .Fn log2f "float x"
60 .Sh DESCRIPTION
61 The following functions compute logarithms:
62 .Bl -bullet -offset 2n
63 .It
64 The
65 .Fn log
66 and
67 .Fn logf
68 functions return the natural logarithm.
69 .It
70 The
71 .Fn log10
72 and
73 .Fn log10f
74 functions return the base 10 logarithm.
75 .It
76 The
77 .Fn log1p
78 and
79 .Fn log1pf
80 functions return the natural logarithm of (1.0 +
81 .Fa x )
82 accurately even for very small values of
83 .Fa x .
84 .It
85 The
86 .Fn log2
87 and
88 .Fn log2f
89 functions return the base 2 logarithm.
90 .El
91 .Sh RETURN VALUES
92 Upon successful completion, the functions return the logarithm of
93 .Fa x
94 as descibed above.
95 Otherwise the following may occur:
96 .Bl -enum -offset indent
97 .It
98 If
99 .Fa x
100 is \*(Na, all functions return \*(Na.
101 .It
102 If
103 .Fa x
104 is positive infinity, all functions return
105 .Fa x .
106 If
107 .Fa x
108 is negative infinity, all functions return \*(Na.
109 .It
110 If
111 .Fa x
112 is +0.0 or -0.0, the
113 .Fn log ,
114 .Fn log10 ,
115 and
116 .Fn log2
117 families return either
118 .Dv -HUGE_VAL ,
119 .Dv -HUGE_VALF ,
120 or
121 .Dv -HUGE_VALL ,
122 whereas the
123 .Fn log1p
124 family returns
125 .Fa x .
126 .It
127 If
128 .Fa x
129 is +1.0, the
130 .Fn log ,
131 .Fn log10 ,
132 and
133 .Fn log2
134 families return +0.0.
135 If
136 .Fa x
137 is -1.0, the
138 .Fn log1p
139 family returns
140 .Dv -HUGE_VAL ,
141 .Dv -HUGE_VALF ,
142 or
143 .Dv -HUGE_VALL .
144 .El
145 .Pp
146 In addition, on a
147 .Tn VAX ,
148 .Va errno
149 is set to
150 .Er EDOM
151 and the reserved operand is returned
152 by
153 .Fn log
154 unless
155 .Fa x
156 \*[Gt] 0, by
157 .Fn log1p
158 unless
159 .Fa x
160 \*[Gt] \-1.
161 .Sh SEE ALSO
162 .Xr exp 3 ,
163 .Xr ilogb 3 ,
164 .Xr math 3
165 .Sh STANDARDS
166 The described functions conform to
167 .St -isoC-99 .
168 .Sh HISTORY
169 The history of the logarithm functions dates back to
170 .At v6 .