log.3 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. .\" Copyright (c) 2008-2010 David Schultz <[email protected]>
  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: src/lib/msun/man/log.3,v 1.2 2010/12/05 22:11:22 das Exp $
  26. .\"
  27. .Dd December 5, 2010
  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 log2 ,
  37. .Nm log2f ,
  38. .Nm log1p ,
  39. .Nm log1pf
  40. .Nd logarithm functions
  41. .Sh LIBRARY
  42. .Lb libm
  43. .Sh SYNOPSIS
  44. .In math.h
  45. .Ft double
  46. .Fn log "double x"
  47. .Ft float
  48. .Fn logf "float x"
  49. .Ft double
  50. .Fn log10 "double x"
  51. .Ft float
  52. .Fn log10f "float x"
  53. .Ft double
  54. .Fn log2 "double x"
  55. .Ft float
  56. .Fn log2f "float x"
  57. .Ft double
  58. .Fn log1p "double x"
  59. .Ft float
  60. .Fn log1pf "float x"
  61. .Sh DESCRIPTION
  62. The
  63. .Fn log
  64. and
  65. .Fn logf
  66. functions compute the natural logarithm of
  67. .Fa x .
  68. .Pp
  69. The
  70. .Fn log10
  71. and
  72. .Fn log10f
  73. functions compute the logarithm base 10 of
  74. .Fa x ,
  75. while
  76. .Fn log2
  77. and
  78. .Fn log2f
  79. compute the logarithm base 2 of
  80. .Fa x .
  81. .Pp
  82. The
  83. .Fn log1p
  84. and
  85. .Fn log1pf
  86. functions compute the natural logarithm of
  87. .No "1 + x" .
  88. Computing the natural logarithm as
  89. .Li log1p(x)
  90. is more accurate than computing it as
  91. .Li log(1 + x)
  92. when
  93. .Fa x
  94. is close to zero.
  95. .Sh RETURN VALUES
  96. These functions return the requested logarithm; the logarithm of 1 is +0.
  97. An attempt to take the logarithm of \*(Pm0 results in a divide-by-zero
  98. exception, and -\*(If is returned.
  99. Otherwise, attempting to take the logarithm of a negative number
  100. results in an invalid exception and a return value of \*(Na.
  101. .Sh SEE ALSO
  102. .Xr exp 3 ,
  103. .Xr ilogb 3 ,
  104. .Xr math 3 ,
  105. .Xr pow 3
  106. .Sh STANDARDS
  107. The
  108. .Fn log ,
  109. .Fn logf ,
  110. .Fn log10 ,
  111. .Fn log10f ,
  112. .Fn log2 ,
  113. .Fn log2f ,
  114. .Fn log1p ,
  115. and
  116. .Fn log1pf
  117. functions conform to
  118. .St -isoC-99 .