Approximating $f(x)$ with a power series, how many terms I need to obtain $n$ significant figures of accuracy at $x=x_0$ (no computer allowed)?

67 Views Asked by At

Robert L. Parker in his 1994 book Geophysical Inverse Theory wrote:

The definition of $\mathrm{dilog}$

$\mathrm{dilog}(1+x)=-\int_0^x\frac{\ln(1+t)}{t}dt, x\geq-1$,

naturally gives rise to the power series

$\mathrm{dilog}(1-x)=x+\frac{x^2}{2^2}+\frac{x^3}{3^2}+\ldots$ $|x|\leq1$.

Can the reader estimate how many terms would be needed to obtain four significant figures of accuracy at $x=1$?

How can I answer his question?

Let's pretend I am able to compute $-\int_0^{-1}\frac{\ln(1+t)}{t}dt$: I am not able to do it but Wolfram Alpha tells me it is $\frac{\pi^2}{6}\approx 1.64493406685$.

Now I would write a very naïve program in Python:

import math
target = math.pi**2/6
acc =0
i = 1
while(abs(target-acc)>1e-3):
    acc = acc + 1/(i**2)
    print(i,acc)
    i = i+1

and the answer is 1000 (to me four significant figures means one for $10^0$ position and then three digits after the floating point, so an error of $\frac{1}{1000}$):

      1 1.0
      2 1.25
      3 1.3611111111111112
      4 1.4236111111111112
      5 1.4636111111111112
      6 1.4913888888888889
      7 1.511797052154195
      8 1.527422052154195
      9 1.5397677311665408
     10 1.5497677311665408
    ...
    997 1.6439315606665255
    998 1.6439325646785576
    999 1.6439335666815615
   1000 1.6439345666815615

How can I answer the question without using a computer?

1

There are 1 best solutions below

0
On

You just need to use the remainder in Taylor's approximation to estimate the error...

$$ f(x)=f(a) + f'(a) (x-a) + \cdots + \frac{f^{(k)}(a)}{k!} (x-a)^k + \frac{f^{(k+1)}(\xi)}{(k+1)!} (x-a)^{k+1} $$

Given $a$ and $x$, you compute $k$ such that

$$ \dfrac{\|f^{(k+1)}\|_{\infty}}{(k+1)!}\cdot |x-a|^{k+1}\leq 0.5 \times 10^{-n}. $$