How can I approximate $\log(1+b/a)$?

295 Views Asked by At

I know that $\log(a+b)=\log(a) + \log(1+\frac{b}{a})$. I also know that Taylor approximation allows to approximate $\log(1+c)$ to $c$. However, is there a way to smartly transform / approximate $\log(1+\frac{b}{a})$ into something like: $\log(b)-\log(a)$ or $b - a$ ? I guess not...but I would still like to ask

4

There are 4 best solutions below

0
On

WLOG , we can assume $a\ge b$

Then, we have $$\ln(a+b)=\ln(a)+\ln(1+\frac{b}{a})\approx \ln(a)+\frac{b}{a}$$ which is a good approximation , if $b<<a$ holds.

0
On

As Peter already answered $$\log(a+b)=\log(a)+\log\left(1+\frac{b}{a}\right)$$ Now let $$1+\frac{b}{a}=\frac{1+x}{1-x}\implies x=\frac{b}{2 a+b}$$ and use the very fast convergent $$\log\left(\frac{1+x}{1-x}\right)=2 \left(x+\frac{x^3}3 +\frac{x^5}5+\cdots\right)$$

Let us compute $$\log(123)=\log(100)+\log\left(1+\frac{23}{100}\right)\implies x=\frac{23}{223}$$ So $$\log(123)=\log(100)+2 \left(\frac{23}{223}+\frac 13 \left(\frac{23}{223}\right)^3+\frac 15 \left(\frac{23}{223}\right)^5\right)$$ gives $4.812184320$ while the exact value is $4.812184355$

0
On

The answer is no.

$$\log\left(1+\frac ba\right)$$ is a nonlinear function of $\dfrac ba$, which you should see as a single variable, let $x$.

For small $x$, you can indeed use the Taylor development. For large $x$, you can divide $1+x$ by $e$ several times until the ratio becomes less than $1$, and use

$$\log(1+x)=n+\log\left(\frac{1+x}{e^n}\right)=n+\log\left(1-\left(1-\frac{1+x}{e^n}\right)\right),$$ where $1-\dfrac{1+x}{e^n}$ is small.

0
On

While Claude already gave a good answer, I want to elaborate a bit on where $$\log\left(\frac{1+x}{1-x}\right)=2(x+x^3/3+x^5/5+\ldots)$$

comes from and why it is such a good approximation. It is easy to see that it is true using the standard Taylor series for $\log(1+x)$ and the fact that $\log\left(\frac{1+x}{1-x}\right)=\log(1+x)-\log(1-x)$.

There are a few reasons why it is such a useful formula. First, even though it only has a radius of convergence of 1 (just like the Taylor series for $\log(1+x)$), for any $a>0$, we can still solve $a=\frac{1+x}{1-x}$ with $|x-1|<1$, so this allows us to compute $\log(a)$ for arbitrary $a$, not just $a$ close to $1$.

Second, because we only have odd powers of $x$, if $|x|<<1$, our terms are approaching $0$ twice as fast as we otherwise would.

But most important, if $a=\frac{1+x}{1-x}$, $x$ is significantly closer to $0$ than $a$ was to $1$. To give an extreme example, if we wanted to compute $\log(2)$ using $1-1/2+1/3-1/4+\ldots$, convergence is abysmally slow. We don't even have any exponential decay to help. But $2=\frac{1+1/3}{1-1/3}$, and so each term in the new series is smaller by a factor of approximately $1/9$, so we gain about a digit of precision for each term we take.

But if we solve $1+1/n=(1+x)/(1-x)$, we get $x=1/(2n+1)$, and so after $k$ terms, instead of being on the order of $n^{-k}$, we are on the order of $(2n)^{-2k}$. This is a significant speedup.