xref: /freebsd/lib/msun/man/log.3 (revision dc60165b73e4c4d829a2cb9fed5cce585e93d9a9)
1.\" Copyright (c) 2008 David Schultz <das@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd January 17, 2008
28.Dt LOG 3
29.Os
30.Sh NAME
31.Nm log ,
32.Nm logf ,
33.Nm logl ,
34.Nm log10 ,
35.Nm log10f ,
36.Nm log1p ,
37.Nm log1pf
38.Nd logarithm functions
39.Sh LIBRARY
40.Lb libm
41.Sh SYNOPSIS
42.In math.h
43.Ft double
44.Fn log "double x"
45.Ft float
46.Fn logf "float x"
47.Ft double
48.Fn log10 "double x"
49.Ft float
50.Fn log10f "float x"
51.Ft double
52.Fn log1p "double x"
53.Ft float
54.Fn log1pf "float x"
55.Sh DESCRIPTION
56The
57.Fn log
58and
59.Fn logf
60functions compute the natural logarithm of
61.Fa x .
62.Pp
63The
64.Fn log10
65and
66.Fn log10f
67functions compute the logarithm base 10 of
68.Fa x .
69.Pp
70The
71.Fn log1p
72and
73.Fn log1pf
74functions compute the natural logarithm of
75.No "1 + x" .
76Computing the natural logarithm as
77.Li log1p(x)
78is more accurate than computing it as
79.Li log(1 + x)
80when
81.Fa x
82is close to zero.
83.Sh RETURN VALUES
84These functions return the requested logarithm; the logarithm of 1 is +0.
85An attempt to take the logarithm of \*(Pm0 results in a divide-by-zero
86exception, and -\*(If is returned.
87Otherwise, attempting to take the logarithm of a negative number
88results in an invalid exception and a return value of \*(Na.
89.Sh SEE ALSO
90.Xr exp 3 ,
91.Xr ilogb 3 ,
92.Xr math 3 ,
93.Xr pow 3
94.Sh STANDARDS
95The
96.Fn log ,
97.Fn logf ,
98.Fn log10 ,
99.Fn log10f ,
100.Fn log1p ,
101and
102.Fn log1pf
103functions conform to
104.St -isoC-99 .
105