24

At small values close to $x=1$, you can use taylor expansion for $\ln x$:

$$ \ln x = (x-1) - \frac{1}{2}(x-1)^2 + ....$$

Is there any valid expansion or approximation for large values (or at infinity)?

smörkex
  • 601

9 Answers9

26

Almost as Semiclassical answered, write $x=A \times 10^{n-1}$ where $n$ is the number of digits before the decimal point, that is to say $1\leq A < 10$ and use the very fast converging expansion $$\log \left(\frac{1+y}{1-y}\right)=2\sum_{k=0}^{\infty}\frac{y^{2 k+1}}{2 k+1}$$ with $y=\frac{A-1}{A+1}$.

Let us take an example : $x=123456789$; then $A=1.23456789$ and $n=8$; so $y \approx 0.104972$. Now, let us look at the value of $$S_p=2\sum_{k=0}^{p}\frac{y^{2 k+1}}{2 k+1}$$ For the first values of $p$, the sums are successively $0.2099447424$, $0.2107158833$, $0.2107209817$, $0.2107210219$, $0.2107210222$ which is the solution for ten exact decimal places.

So, by the end $$\log^{(p)}(x)=(n-1)\log(10)+ S_p$$ which leads to the successive values of $18.63062549$, $18.63139663$ ,$18.63140173$, $18.63140177$, $18.63140177$ for an exact value equal to $\approx 18.63140177$.

16

for any positive $x$

$\ln \left( x \right) \approx a{x^{\frac{1}{a}}} - a$
where $a$ is any large constant

The larger $a$, the better approximation.

5

There is no polynomial or rational approximation to $\ln(x)$ that is accurate for all large $x$.

This follows from the fact that $\ln(x) =o(x^{\epsilon}) $ for every $\epsilon > 0$.

marty cohen
  • 107,799
4

The Taylor series for $\ln(\cdot)$ in the vicinity of point $a$ is

$$\ln(x+a) =\ln(a) + 2 \cdot \left(y+\frac{y^3}{3}+\frac{y^5}{5}+\frac{y^7}{7} + \ldots + \frac{y^{2n+1}}{2n+1}\right), \text{ where } y=\frac{x}{x+2a}$$

So for fast convergence, we need the logarithms of first $26$ prime numbers: $2,3,5,7,\ldots$.

Gary
  • 31,845
Florin
  • 41
  • 2
    Please use MathJax to provide mathematical equations: https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference – jvdhooft Jun 01 '17 at 09:16
4

A crude approach is to assume scientific notation: If $x=A \times 10^n$ where $1\leq A < 10$. Then $\ln x = \ln A + n\ln 10\approx 2.3n$. To be a little more precise, we know $\ln x\in [n \ln 10,(n+1)\ln 10)$.

Semiclassical
  • 15,842
  • Given that the commonly used taylor series approximation of ln(1+x) is defined for $|x| < 1$, how do you obtain $\ln(A)$ or $\ln(10)$ ? – IntegrateThis Aug 27 '21 at 08:39
  • For Ln(10) factor the 10 into 1.25 x 2 x 2, and sum the logs of the factors. But the power series in not an efficient way to do it. A much better way is by integrating. – richard1941 Nov 29 '21 at 06:38
2

If the number whose logarithm you require is real and positive, Borchardt's algorithm, which is similar in structure to Gauss' AGM algorithm, if started with initial values 1 and x, will converge to (x-1)/Ln(x) for large values of x, although many steps will be required, each involves a square root, and convergence is not quadratic. From this, Ln(x) can easily be calculated. However, convergence can be accelerated by extrapolation methods well known to the number crunching community. Borchardt's algorithm was a popular way to compute logarithms by FORTH programmers in the last century.

Another popular method for computing logarithms was to compute the exponential function (inverse of the desired logarithm function) of an initial guess. Exponential function is a rapidly converging power series, so it is quickly computed. A solver routine then adjusts the approximation to get the desired logarithm. If your number is in floating point, you can extract an appropriate guess for the logarithm from the biased exponent portion of the floating point notation.

There is no rational function (or polynomial) that will do the job. To see this, suppose the power of the denominator is greater than the numerator. For large values, the rational function will approach zero. The logarithm does not. Suppose the power of the numerator and denominator are equal. Then for large values of x the rational function approaches a constant. The logarithm does not. And if the power of the numerator is greater, the rational function grows at least linearly; the logarithm does not. So there is no rational function (or polynomial) that can approximate the logarithm for large values.

That being said, rational functions called Pade approximations beat truncated power series. This is because the Pade approximation, when expanded into a power series matches the truncated power series for several terms, and then includes additional terms of higher power that approximately match terms of the logarithm series that were cut off. To learn about Pade approximation, see a text on continued fractions. Otherwise, if you are lazy, Wolfram has a continued fraction generator on line.

Much has been learned since the time of Napier and Briggs.

  • @ richard1941 -- Those fractional exponents must be inside grouping symbols because of the Order of Exponents. – Olive Stemforn Aug 07 '22 at 18:42
  • I have edited my answer to avoid possible objections. I provide two answers and an explanation of why a simple formula cannot do the job for large values of the argument. Olive Stemforn comment above was correct, but is no longer valid. – richard1941 Aug 08 '22 at 22:01
2

Hint: $~\ln x=-\ln\dfrac1x~:~$ Can you take it from here ?

Lucian
  • 48,334
  • 2
  • 83
  • 154
  • 10
    I'm not sure what you're suggesting. Could you elaborate? – Antonio Vargas Oct 17 '14 at 02:31
  • @AntonioVargas: Are you referring to the very slow convergence of $~\displaystyle\sum_{n=1}^\infty\dfrac1n\bigg(1-\dfrac1x\bigg)^n~$ ? – Lucian Oct 17 '14 at 03:36
  • If that is what you were suggesting then yes. It converges ever more slowly as $x$ grows larger. Taking only finitely many terms of that series yields an approximation that is "good" only when $1/x$ is close to $1$ (and so when $x$ itself is close to $1$). – Antonio Vargas Oct 17 '14 at 04:08
  • @AntonioVargas: I agree ! My idea was that for $x>1$ the series from the original post diverges. Obviously, slow convergence beats divergence. – Lucian Oct 17 '14 at 04:18
1

x-1 is a crude approximation that is good for values of x close to 1.
2*(x-1)/(x+1) is a better approximation with a larger range. 6*(x-1)/(1 + 4 * Sqrt(x) + x) is better and has an even larger range. 90*(x-1)/(7+32 * x^(1/4) + 12 * x^(1/2) + 32 * x^(3/4) + 7 * x) is even better and has a larger range, but it never exceeds 90 for any positive real value of x.

Some such approximations are better than others, but any of these fail for sufficiently large x.

(Note that the fourth root in that last formula can be found by taking the square root twice).

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. - From Review – GoodDeeds Mar 03 '16 at 02:09
  • @GoodDeeds... I revised this anwer to provide several approximations of increasing range, though even the last and best will fail for sufficiently large arguments as explained above. Note that all of these use approximations for the integral 0 to 1 of x^t dt. – richard1941 Aug 08 '22 at 22:40
0

In this other question I found an approximation as follows: $$\ln(x+1) \approx \dfrac{\ln(x)}{1-x^{-\frac{1}{\ln(2)}}}$$

By differentiating both sides, since just one logarithmic terms remains you could find the following approximation: $$\ln(x)\approx \dfrac{\ln(2)\ x^{-\frac{1}{\ln(2)}}\left(x^{\frac{1}{\ln(2)}}-1\right)\left(x^{\frac{1}{\ln(2)}}+x\right)}{1+x}$$

which works pretty good for $x\in [0.1,\ 10]$ as can be seen in Wolfram-Alpha, but it get worst for bigger values of $x$, but anyway, maybe it could be improved knowing how it has been done.

approximation 1

For bigger values of $x$, following this answer, this formula could be used:

$$\ln(x)\approx x\ \left(x^\frac{1}{x}-1\right)$$

approx 2


Added later

Later I found here that the first approximation could be improved with an even simpler formula, which works quite good for $x\in [0.02,\ 50]$:

$$\ln(x) \approx = \frac{\left(x-1\right)\left(x+x^{\ln(2)}\right)}{x\left(1+x^{\ln(2)}\right)}$$

check its plot:

simpler approx

Joako
  • 1,380
  • How do you compute $x^{1/x}$? – Gary Mar 08 '24 at 07:09
  • @Gary Could you elaborate in were is the problem? That kind of functions are commonly used for making smooth bump functios as is seen in this answer, so I am honestly curious why they are not "useful" in the sense of the current question – Joako Mar 17 '24 at 02:46
  • 1
    Is it easier to compute $x^{1/x}$ than $\log x$? – Gary Mar 17 '24 at 04:59
  • @Gary I am attempting to improve the answer here, but I got stuck. But so far I have been able to find some approximations that works better than the first one list here: plot. – Joako Mar 21 '24 at 22:38