How many terms of $ln(2)=1-\dfrac{1}{2}+\dfrac{1}{3}-\dfrac{1}{4}$ are needed to approximate it with an error of less than $5*10^{-3}$?
Approximating $\ln(2)$ with error of $5*10^{-3}$?
184 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 3 best solutions below
On
Suppose, we can compute $\ln\frac{3^2}{2^3}$, $\ln\frac{3^3}{5^2}$, and $\ln\frac{2^7}{5^3}$ with errors $<\epsilon$. Then $$\tag1\ln 2=9\ln\frac{3^2}{2^3} -6\ln\frac{3^3}{5^2}+4\ln\frac{2^7}{5^3}$$ with error $< 19\epsilon$. To compute $\ln\frac 98$ etc., we can us use $$ \ln(1+x)=\sum_{k=1}^\infty \frac{(-1)^{k+1}}kx^{k}$$ and very naively stop when the next summands of this alternating series would become $<2\cdot 10^{-4}$: $$\begin{align}\ln\frac98&\approx \frac18-\frac1{2\cdot 8^2}+{\frac1{3\cdot 8^3}}&\frac1{4\cdot 8^4}<0.0001\\ \ln\frac{27}{25}&\approx \frac2{25}-\frac{2^2}{2\cdot 25^2}&{\frac{2^3}{3\cdot 25^3}}{<0.0002}\\ \ln\frac{128}{125}&\approx \frac 3{125}&\frac{3^2}{2\cdot 125^2}<0.0003 \end{align}$$ So using these in total six terms in $(1)$, our error is certainly below $$9\cdot0.0001+6\cdot0.0002+4\cdot 0.0003 =0.0033<5\cdot 10^{-3}.$$
If we use the same stopping criterion directly with the alternating series $$ \ln 2= \sum_{k=1}^\infty\frac{(-1)^{k+1}}{k},$$ we need to continue until the next summand is $<5\cdot 10^{-3}$, that is until $k=200$.
On
It's a general feature of alternating series whose terms are monotonically decreasing in absolute value that the error in taking the first $n$ terms is bounded by the next term (the $n+1$ term). So it suffices to take $\boxed{ n = 200 }$.
This is a lot of terms. A different series that converges much faster is
$$\ln 2 = \ln \left( \frac{1}{1 - \frac{1}{2}} \right) = \sum_{k \ge 1} \frac{1}{k \cdot 2^k}$$
which comes from the Taylor series
$$\ln \left( \frac{1}{1 - x} \right) = \sum_{k \ge 1} \frac{x^k}{k}.$$
The error in taking the first $n$ terms is bounded by
$$\sum_{k \ge n+1} \frac{1}{k \cdot 2^k} \lt \sum_{k \ge n+1} \frac{1}{(n+1) 2^k} = \frac{1}{(n+1) 2^n}$$
which gives that this time it suffices to take $\boxed{ n = 7 }$. Much better!
Recently I tried computing $\ln 2$ to $3$ digits of accuracy by hand for fun and I found out that there is yet another series that converges even faster. We have
$$\begin{eqnarray} \ln 2 &=& \ln \frac{3}{2} + \ln \frac{4}{3} \\ &=& \ln \left( \frac{1}{1 - \frac{1}{3}} \right) + \ln \left( 1 + \frac{1}{3} \right) \\ &=& \sum_{k \ge 1} \frac{1 + (-1)^{k-1}}{k \cdot 3^k} \\ &=& \boxed{ \sum_{k \ge 0} \frac{2}{(2k+1) 3^{2k+1}}. } \end{eqnarray}$$
The terms of this series decay like $\frac{1}{9^k}$ which is more than $3$ times faster (as measured by the number of digits of accuracy you gain per term) than the $\frac{1}{2^k}$ we had before. This series comes from the Taylor series
$$\frac{1}{2} \ln \frac{1+x}{1-x} = \text{arctanh } x = \sum_{k \ge 0} \frac{x^{2k+1}}{2k+1}$$
for the hyperbolic arctangent. The error in taking the first $n$ terms is bounded by
$$\sum_{k \ge n} \frac{2}{(2k+1) 3^{2k+1}} \le \sum_{k \ge n} \frac{2}{(2n+1) 3^{2k+1}} = \frac{1}{4(2n+1) 3^{2n-1}}$$
which gives that this time it suffices to take $\boxed{ n = 2 }$, which gives us an accuracy of better than $\frac{1}{540}$. And in fact the sum of the first two terms is
$$\frac{2}{3} + \frac{2}{81} = \frac{56}{81} = 0.6913 \dots $$
and the sum of the first two terms plus the error bound above is
$$\frac{2}{3} + \frac{2}{81} + \frac{1}{540} = \frac{1123}{1640} = 0.6932 \dots $$
which is accurate to better than $0.000063$.
There is a formula to calculate the error.
https://en.wikipedia.org/wiki/Taylor%27s_theorem#Explicit_formulas_for_the_remainder
$$\text{Error}_n=\frac{f^{(n+1)}(\xi)}{(n+1)!}(x-a)^{n+1}$$
In your case, $f(x)=\ln(x+1)$, $x=1$, $a=0$.