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