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!
==Efficient computation==<!-- This section is linked from [[Common logarithm]] --> For <math>\ln (x)</math> where {{math|''x'' > 1}}, the closer the value of {{mvar|x}} is to 1, the faster the rate of convergence of its Taylor series centered at 1. The identities associated with the logarithm can be leveraged to exploit this: <math display="block">\begin{align} \ln 123.456 &= \ln(1.23456 \cdot 10^2)\\ &= \ln 1.23456 + \ln(10^2)\\ &= \ln 1.23456 + 2 \ln 10\\ &\approx \ln 1.23456 + 2 \cdot 2.3025851. \end{align}</math> Such techniques were used before calculators, by referring to numerical tables and performing manipulations such as those above. ===Natural logarithm of 10=== The natural logarithm of 10, approximately equal to {{math|{{val|2.30258509}}}},<ref>{{Cite OEIS|A002392|Decimal expansion of natural logarithm of 10}}</ref> plays a role for example in the computation of natural logarithms of numbers represented in [[scientific notation]], as a [[Mantissa (logarithm)|mantissa]] multiplied by a power of 10: <math display="block">\ln(a\cdot 10^n) = \ln a + n \ln 10.</math> This means that one can effectively calculate the logarithms of numbers with very large or very small [[magnitude (mathematics)|magnitude]] using the logarithms of a relatively small set of decimals in the range {{math|[1, 10)}}. ==={{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'')}}. ===Computational complexity=== {{main|Computational complexity of mathematical operations}} The [[Computational complexity theory|computational complexity]] of computing the natural logarithm using the [[Arithmetic–geometric mean|arithmetic-geometric mean]] (for both of the above methods) is <math>\text{O}\bigl(M(n) \ln n \bigr)</math>. Here, {{mvar|n}} is the number of digits of precision at which the natural logarithm is to be evaluated, and {{math|''M''(''n'')}} is the computational complexity of multiplying two {{mvar|n}}-digit numbers.
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)