Split out the logarithm functions from the perplex exp(3). Also remove some
useless notes in the latter (namely, no one cares that financial calculations were done on Hewlett-Packard HP-71B, or that there is a LN1() in Pascal).
This commit is contained in:
parent
a5f70e6aac
commit
6fd7775f29
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.118 2011/08/06 11:01:12 jruoho Exp $
|
||||
# $NetBSD: Makefile,v 1.119 2011/09/13 05:26:47 jruoho Exp $
|
||||
#
|
||||
# @(#)Makefile 5.1beta 93/09/24
|
||||
#
|
||||
@ -210,7 +210,7 @@ MAN+= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \
|
||||
ceil.3 copysign.3 cos.3 cosh.3 \
|
||||
erf.3 exp.3 \
|
||||
fabs.3 finite.3 fmod.3 frexp.3 hypot.3 \
|
||||
ieee_test.3 ilogb.3 isinff.3 j0.3 ldexp.3 lgamma.3 lrint.3 \
|
||||
ieee_test.3 ilogb.3 isinff.3 j0.3 ldexp.3 lgamma.3 log.3 lrint.3 \
|
||||
math.3 modf.3 nextafter.3 \
|
||||
remainder.3 rint.3 round.3 \
|
||||
scalbn.3 sin.3 sinh.3 sqrt.3 \
|
||||
@ -246,11 +246,14 @@ MLINKS+=cosh.3 coshf.3
|
||||
MLINKS+=erf.3 erff.3 erf.3 erfc.3 erf.3 erfcf.3
|
||||
MLINKS+=exp.3 expf.3 exp.3 expm1.3 exp.3 expm1f.3 \
|
||||
exp.3 exp2.3 exp.3 exp2f.3 \
|
||||
exp.3 log.3 exp.3 logf.3 \
|
||||
exp.3 log10.3 exp.3 log10f.3 \
|
||||
exp.3 log1p.3 exp.3 log1pf.3 \
|
||||
exp.3 pow.3 exp.3 powf.3 \
|
||||
exp.3 log2.3 exp.3 log2f.3
|
||||
exp.3 pow.3 exp.3 powf.3
|
||||
MLINKS+=log.3 logf.3 \
|
||||
log.3 log10.3 \
|
||||
log.3 log10f.3 \
|
||||
log.3 log1p.3 \
|
||||
log.3 log1pf.3 \
|
||||
log.3 log2.3 \
|
||||
log.3 log2f.3
|
||||
MLINKS+=fabs.3 fabsf.3
|
||||
MLINKS+=finite.3 finitef.3
|
||||
MLINKS+=fmod.3 fmodf.3
|
||||
|
@ -27,9 +27,9 @@
|
||||
.\"
|
||||
.\" from: @(#)exp.3 6.12 (Berkeley) 7/31/91
|
||||
.\" $FreeBSD: src/lib/msun/man/exp.3,v 1.24 2008/01/18 21:43:00 das Exp $
|
||||
.\" $NetBSD: exp.3,v 1.26 2010/05/03 05:35:58 jruoho Exp $
|
||||
.\" $NetBSD: exp.3,v 1.27 2011/09/13 05:26:47 jruoho Exp $
|
||||
.\"
|
||||
.Dd May 3, 2010
|
||||
.Dd September 13, 2011
|
||||
.Dt EXP 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -41,17 +41,9 @@
|
||||
.\" .Nm exp2l ,
|
||||
.Nm expm1 ,
|
||||
.Nm expm1f ,
|
||||
.Nm log ,
|
||||
.Nm logf ,
|
||||
.Nm log2 ,
|
||||
.Nm log2f ,
|
||||
.Nm log10 ,
|
||||
.Nm log10f ,
|
||||
.Nm log1p ,
|
||||
.Nm log1pf ,
|
||||
.Nm pow ,
|
||||
.Nm powf
|
||||
.Nd exponential, logarithm, power functions
|
||||
.Nd exponential and power functions
|
||||
.Sh LIBRARY
|
||||
.Lb libm
|
||||
.Sh SYNOPSIS
|
||||
@ -71,22 +63,6 @@
|
||||
.Ft float
|
||||
.Fn expm1f "float x"
|
||||
.Ft double
|
||||
.Fn log "double x"
|
||||
.Ft float
|
||||
.Fn logf "float x"
|
||||
.Ft double
|
||||
.Fn log2 "double x"
|
||||
.Ft float
|
||||
.Fn log2f "float x"
|
||||
.Ft double
|
||||
.Fn log10 "double x"
|
||||
.Ft float
|
||||
.Fn log10f "float x"
|
||||
.Ft double
|
||||
.Fn log1p "double x"
|
||||
.Ft float
|
||||
.Fn log1pf "float x"
|
||||
.Ft double
|
||||
.Fn pow "double x" "double y"
|
||||
.Ft float
|
||||
.Fn powf "float x" "float y"
|
||||
@ -118,31 +94,6 @@ functions computes the value exp(x)\-1 accurately even for tiny argument
|
||||
.Fa x .
|
||||
.Pp
|
||||
The
|
||||
.Fn log
|
||||
function computes the value of the natural logarithm of argument
|
||||
.Fa x .
|
||||
.Pp
|
||||
The
|
||||
.Fn log10
|
||||
function computes the value of the logarithm of argument
|
||||
.Fa x
|
||||
to base 10.
|
||||
.Pp
|
||||
The
|
||||
.Fn log1p
|
||||
function computes
|
||||
the value of log(1+x) accurately even for tiny argument
|
||||
.Fa x .
|
||||
.Pp
|
||||
The
|
||||
.Fn log2
|
||||
and the
|
||||
.Fn log2f
|
||||
functions compute the value of the logarithm of argument
|
||||
.Fa x
|
||||
to base 2.
|
||||
.Pp
|
||||
The
|
||||
.Fn pow
|
||||
and
|
||||
.Fn powf
|
||||
@ -180,41 +131,15 @@ is set to
|
||||
and on the
|
||||
.Tn VAX
|
||||
generate a reserved operand fault.
|
||||
On a
|
||||
.Tn VAX ,
|
||||
.Va errno
|
||||
is set to
|
||||
.Er EDOM
|
||||
and the reserved operand is returned
|
||||
by log unless
|
||||
.Fa x
|
||||
\*[Gt] 0, by
|
||||
.Fn log1p
|
||||
unless
|
||||
.Fa x
|
||||
\*[Gt] \-1.
|
||||
.Sh ERRORS
|
||||
The values of
|
||||
.Fn exp x ,
|
||||
.Fn expm1 x ,
|
||||
.Fn exp2 x ,
|
||||
.Fn log x ,
|
||||
and
|
||||
.Fn log1p x ,
|
||||
.Fn exp2 x ,
|
||||
are exact provided that they are representable.
|
||||
Otherwise the error in these functions is generally below one
|
||||
.Em ulp .
|
||||
The values of
|
||||
.Fn log10 x
|
||||
are within about 2
|
||||
.Em ulps ;
|
||||
an
|
||||
.Em ulp
|
||||
is one
|
||||
.Em Unit
|
||||
in the
|
||||
.Em Last
|
||||
.Em Place .
|
||||
The error in
|
||||
.Fn pow x y
|
||||
is below about 2
|
||||
@ -248,36 +173,6 @@ is exact until it is bigger than 2**56 on a
|
||||
.Tn IEEE
|
||||
754.
|
||||
.Sh NOTES
|
||||
The functions
|
||||
.Fn exp x\ \-\ 1
|
||||
and
|
||||
.Fn log 1\ \+\ x
|
||||
are called
|
||||
.Fn expm1 x
|
||||
and
|
||||
.Fn logp1 x
|
||||
in
|
||||
.Tn BASIC
|
||||
on the Hewlett\-Packard
|
||||
.Tn HP Ns \-71B
|
||||
and
|
||||
.Tn APPLE
|
||||
Macintosh,
|
||||
.Tn EXP1
|
||||
and
|
||||
.Tn LN1
|
||||
in Pascal,
|
||||
.Fn exp1 x
|
||||
and
|
||||
.Fn log1 x
|
||||
in C
|
||||
on
|
||||
.Tn APPLE
|
||||
Macintoshes, where they have been provided to make
|
||||
sure financial calculations of ((1+x)**n\-1)/x, namely
|
||||
expm1(n*log1p(x))/x, will be accurate when x is tiny.
|
||||
They also provide accurate inverse hyperbolic functions.
|
||||
.Pp
|
||||
The function
|
||||
.Fn pow x 0
|
||||
returns x**0 = 1 for all x including x = 0,
|
||||
@ -340,9 +235,7 @@ and infinite x, i.e., independently of x.
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
The
|
||||
.Fn exp ,
|
||||
.Fn log ,
|
||||
.Fn log10
|
||||
.Fn exp
|
||||
and
|
||||
.Fn pow
|
||||
functions conform to
|
||||
@ -353,33 +246,19 @@ The
|
||||
.Fn expf ,
|
||||
.Fn expm1 ,
|
||||
.Fn expm1f ,
|
||||
.Fn log1p ,
|
||||
.Fn log1pf ,
|
||||
.Fn log2 ,
|
||||
.Fn log2f ,
|
||||
.Fn log10f ,
|
||||
.Fn logf ,
|
||||
and
|
||||
.Fn powf
|
||||
functions conform to
|
||||
.St -isoC-99 .
|
||||
.Sh HISTORY
|
||||
A
|
||||
.Fn exp ,
|
||||
.Fn log
|
||||
.Fn exp
|
||||
and
|
||||
.Fn pow
|
||||
functions
|
||||
appeared in
|
||||
.At v6 .
|
||||
A
|
||||
.Fn log10
|
||||
function
|
||||
appeared in
|
||||
.At v7 .
|
||||
The
|
||||
.Fn log1p
|
||||
and
|
||||
.Fn expm1
|
||||
functions appeared in
|
||||
function appeared in
|
||||
.Bx 4.3 .
|
||||
|
169
lib/libm/man/log.3
Normal file
169
lib/libm/man/log.3
Normal file
@ -0,0 +1,169 @@
|
||||
.\" $NetBSD: log.3,v 1.1 2011/09/13 05:26:47 jruoho Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2011 Jukka Ruohonen <jruohonen@iki.fi>
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd September 13, 2011
|
||||
.Dt SCALBN 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm log ,
|
||||
.Nm logf ,
|
||||
.Nm log10 ,
|
||||
.Nm log10f ,
|
||||
.Nm log1p ,
|
||||
.Nm log1pf
|
||||
.Nm log2 ,
|
||||
.Nm log2f ,
|
||||
.Nd logarithm functions
|
||||
.Sh LIBRARY
|
||||
.Lb libm
|
||||
.Sh SYNOPSIS
|
||||
.In math.h
|
||||
.Ft double
|
||||
.Fn log "double x"
|
||||
.Ft float
|
||||
.Fn logf "float x"
|
||||
.Ft double
|
||||
.Fn log10 "double x"
|
||||
.Ft float
|
||||
.Fn log10f "float x"
|
||||
.Ft double
|
||||
.Fn log1p "double x"
|
||||
.Ft float
|
||||
.Fn log1pf "float x"
|
||||
.Ft double
|
||||
.Fn log2 "double x"
|
||||
.Ft float
|
||||
.Fn log2f "float x"
|
||||
.Sh DESCRIPTION
|
||||
The following functions compute logarithms:
|
||||
.Bl -bullet -offset 2n
|
||||
.It
|
||||
The
|
||||
.Fn log
|
||||
and
|
||||
.Fn logf
|
||||
functions return the natural logarithm.
|
||||
.It
|
||||
The
|
||||
.Fn log10
|
||||
and
|
||||
.Fn log10f
|
||||
functions return the base 10 logarithm.
|
||||
.It
|
||||
The
|
||||
.Fn log1p
|
||||
and
|
||||
.Fn log1pf
|
||||
functions return the natural logarithm of (1.0 +
|
||||
.Fa x )
|
||||
accurately even for very small values of
|
||||
.Fa x .
|
||||
.It
|
||||
The
|
||||
.Fn log2
|
||||
and
|
||||
.Fn log2f
|
||||
functions return the base 2 logarithm.
|
||||
.Sh RETURN VALUES
|
||||
Upon successful completion, the functions return the logarithm of
|
||||
.Fa x
|
||||
as descibed above.
|
||||
Otherwise the following may occur:
|
||||
.Bl -enum -offset indent
|
||||
.It
|
||||
If
|
||||
.Fa x
|
||||
is \*(Na, all functions return \*(Na.
|
||||
.It
|
||||
If
|
||||
.Fa x
|
||||
is positive infinity, all functions return
|
||||
.Fa x .
|
||||
If
|
||||
.Fa x
|
||||
is negative infinity, all functions return \*(Na.
|
||||
.It
|
||||
If
|
||||
.Fa x
|
||||
is +0.0 or -0.0, the
|
||||
.Fn log ,
|
||||
.Fn log10 ,
|
||||
and
|
||||
.Fn log2
|
||||
families return either
|
||||
.Dv -HUGE_VAL ,
|
||||
.Dv -HUGE_VALF ,
|
||||
or
|
||||
.Dv -HUGE_VALL ,
|
||||
whereas the
|
||||
.Fn log1p
|
||||
family returns
|
||||
.Fa x .
|
||||
.It
|
||||
If
|
||||
.Fa x
|
||||
is +1.0, the
|
||||
.Fn log ,
|
||||
.Fn log10 ,
|
||||
and
|
||||
.Fn log2
|
||||
families return +0.0.
|
||||
If
|
||||
.Fa x
|
||||
is -1.0, the
|
||||
.Fn log1p
|
||||
family returns
|
||||
.Dv -HUGE_VAL ,
|
||||
.Dv -HUGE_VALF ,
|
||||
or
|
||||
.Dv -HUGE_VALL .
|
||||
.El
|
||||
.Pp
|
||||
In addition, on a
|
||||
.Tn VAX ,
|
||||
.Va errno
|
||||
is set to
|
||||
.Er EDOM
|
||||
and the reserved operand is returned
|
||||
by
|
||||
.Fn log
|
||||
unless
|
||||
.Fa x
|
||||
\*[Gt] 0, by
|
||||
.Fn log1p
|
||||
unless
|
||||
.Fa x
|
||||
\*[Gt] \-1.
|
||||
.Sh SEE ALSO
|
||||
.Xr exp 3 ,
|
||||
.Xr ilogb 3 ,
|
||||
.Xr math 3
|
||||
.Sh STANDARDS
|
||||
The described functions conform to
|
||||
.St -isoC-99 .
|
||||
.Sh HISTORY
|
||||
The history of the logarithm functions dates back to
|
||||
.At v6 .
|
Loading…
Reference in New Issue
Block a user