Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Natural logarithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==={{anchor|lnp1}}High precision=== To compute the natural logarithm with many digits of precision, the Taylor series approach is not efficient since the convergence is slow. Especially if {{mvar|x}} is near 1, a good alternative is to use [[Halley's method]] or [[Newton's method]] to invert the exponential function, because the series of the exponential function converges more quickly. For finding the value of {{mvar|y}} to give <math>\exp(y)-x=0</math> using Halley's method, or equivalently to give <math>\exp(y/2) -x \exp(-y/2)=0</math> using Newton's method, the iteration simplifies to <math display="block"> y_{n+1} = y_n + 2 \cdot \frac{ x - \exp ( y_n ) }{ x + \exp ( y_n ) } </math> which has [[cubic convergence]] to <math>\ln (x)</math>. Another alternative for extremely high precision calculation is the formula<ref>{{cite journal |author-first1=T. |author-last1=Sasaki |author-first2=Y. |author-last2=Kanada |title=Practically fast multiple-precision evaluation of log(x) |journal=Journal of Information Processing |volume=5 |issue=4 |pages=247β250 |date=1982 |url=http://ci.nii.ac.jp/naid/110002673332 |access-date=2011-03-30}}</ref><ref>{{cite book |author-first1=Timm |author-last1=Ahrendt |title=Stacs 99 |series=Lecture Notes in Computer Science |doi=10.1007/3-540-49116-3_28 |volume=1564 |date=1999 |pages=302β312 |chapter=Fast Computations of the Exponential Function |isbn=978-3-540-65691-3}}</ref> <math display="block">\ln x \approx \frac{\pi}{2 M(1,4/s)} - m \ln 2,</math> where {{mvar|M}} denotes the [[arithmetic-geometric mean]] of 1 and {{math|4/''s''}}, and <math display="block">s = x 2^m > 2^{p/2},</math> with {{mvar|m}} chosen so that {{mvar|p}} bits of precision is attained. (For most purposes, the value of 8 for {{mvar|m}} is sufficient.) In fact, if this method is used, Newton inversion of the natural logarithm may conversely be used to calculate the exponential function efficiently. (The constants <math>\ln 2</math> and [[pi|{{pi}}]] can be pre-computed to the desired precision using any of several known quickly converging series.) Or, the following formula can be used: <math display="block">\ln x = \frac{\pi}{M\left(\theta_2^2(1/x),\theta_3^2(1/x)\right)},\quad x\in (1,\infty)</math> where <math display="block"> \theta_2(x) = \sum_{n\in\Z} x^{(n+1/2)^2}, \quad \theta_3(x) = \sum_{n\in\Z} x^{n^2} </math> are the [[Theta function#Auxiliary functions|Jacobi theta functions]].<ref>{{Cite book |last1=Borwein |first1=Jonathan M. |last2=Borwein| first2=Peter B. |title=Pi and the AGM: A Study in Analytic Number Theory and Computational Complexity |publisher=Wiley-Interscience |year=1987 |edition=First |isbn=0-471-83138-7}} page 225</ref> Based on a proposal by [[William Kahan]] and first implemented in the [[Hewlett-Packard]] [[HP-41C]] calculator in 1979 (referred to under "LN1" in the display, only), some calculators, [[operating system]]s (for example [[Berkeley UNIX 4.3BSD]]<ref name="Beebe_2017"/>), [[computer algebra system]]s and programming languages (for example [[C99]]<ref name="Beebe_2002"/>) provide a special '''natural logarithm plus 1''' function, alternatively named '''LNP1''',<ref name="HP48_AUR">{{cite book |title=HP 48G Series β Advanced User's Reference Manual (AUR) |publisher=[[Hewlett-Packard]] |edition=4 |date=December 1994 |id=HP 00048-90136, 0-88698-01574-2 |orig-year=1993<!-- edition 1 (1993-07) --> |url=http://www.hpcalc.org/details.php?id=6036 |access-date=2015-09-06}}</ref><ref name="HP50_AUR">{{cite book |title=HP 50g / 49g+ / 48gII graphing calculator advanced user's reference manual (AUR) |publisher=[[Hewlett-Packard]] |edition=2 |date=2009-07-14 |orig-year=2005<!-- first published: Edition 1 (2005β09) --> |id=HP F2228-90010 |url=http://www.hpcalc.org/details.php?id=7141 | access-date=2015-10-10}} [http://holyjoe.net/hp/HP_50g_AUR_v2_English_searchable.pdf Searchable PDF]</ref> or '''log1p'''<ref name="Beebe_2002"/> to give more accurate results for logarithms close to zero by passing arguments {{mvar|x}}, also close to zero, to a function {{math|log1p(''x'')}}, which returns the value {{math|ln(1+''x'')}}, instead of passing a value {{mvar|y}} close to 1 to a function returning {{math|ln(''y'')}}.<ref name="Beebe_2002">{{cite web |title=Computation of expm1 = exp(x)β1 |author-first=Nelson H. F. |author-last=Beebe |publisher=Department of Mathematics, Center for Scientific Computing, [[University of Utah]] |location=Salt Lake City, Utah, USA |date=2002-07-09 |version=1.00 |url=http://www.math.utah.edu/~beebe/reports/expm1.pdf |access-date=2015-11-02}}</ref><ref name="HP48_AUR"/><ref name="HP50_AUR"/> The function {{math|log1p}} avoids in the floating point arithmetic a near cancelling of the absolute term 1 with the second term from the Taylor expansion of the natural logarithm. This keeps the argument, the result, and intermediate steps all close to zero where they can be most accurately represented as floating-point numbers.<ref name="HP48_AUR"/><ref name="HP50_AUR"/> In addition to base {{mvar|e}}, the [[IEEE 754-2008]] standard defines similar logarithmic functions near 1 for [[binary logarithm|binary]] and [[decimal logarithm]]s: {{math|log<sub>2</sub>(1 + ''x'')}} and {{math|log<sub>10</sub>(1 + ''x'')}}. Similar inverse functions named "[[expm1]]",<ref name="Beebe_2002"/> "expm"<ref name="HP48_AUR"/><ref name="HP50_AUR"/> or "exp1m" exist as well, all with the meaning of {{math|1=expm1(''x'') = exp(''x'') β 1}}.<ref group="nb" name="Alternative_funcs">For a similar approach to reduce [[round-off error]]s of calculations for certain input values see [[trigonometric function]]s like [[versine]], [[vercosine]], [[coversine]], [[covercosine]], [[haversine]], [[havercosine]], [[hacoversine]], [[hacovercosine]], [[exsecant]] and [[excosecant]].</ref> An identity in terms of the [[artanh|inverse hyperbolic tangent]], <math display="block">\mathrm{log1p}(x) = \log(1+x) = 2 ~ \mathrm{artanh}\left(\frac{x}{2+x}\right)\,,</math> gives a high precision value for small values of {{mvar|x}} on systems that do not implement {{math|log1p(''x'')}}.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)