Numerical Evaluation of a Series at a Point

65 Views Asked by At

I have a numerical calculus challenge to resolve using a C++ algorithm or scilab. The problem is the following:

$f(x)=\sum_{n=1}^{\infty }a_{n}x^{n}$

where $a_{n}=\sqrt{n^2+1}-n$

This function is defined for $-1\leqslant x<1$

I need to evaluate the function with 10 correct digits at: $$f(0.99)$$ $$f(0.999)$$ $$f(-1)$$

For the first one I tried to use brute force to stop the series at its 1000000th part and it worked pretty well. But for the second, it needs a lot more to get where I need and for the third I cant get anywhere near where it stops to grow.

I tried to find in the internet numerical methods to evaluate series but I was unable to find. Do you have any hint about how can I get this values with less cost?

Thank you for your help

1

There are 1 best solutions below

6
On BEST ANSWER

One idea I have is to consider the behavior of the coefficient for large $n$:

$$\sqrt{n^2+1}-n = \frac1{\sqrt{n^2+1}+n} \sim \frac1{2 n}$$

And we know that

$$\sum_{n=1}^{\infty} \frac{x^n}{2 n} = -\frac12 \log{(1-x)} $$

So...numerically find the sum

$$g(x) = \sum_{n=1}^{N} \left (\frac1{\sqrt{n^2+1}+n} - \frac1{2 n} \right ) x^n $$

and the sum you want is $f(x) \approx g(x) - \frac12 \log{(1-x)} $. Note that the you can get about $10^{-5}$ accuracy with $N=25$ terms, even better with smaller $x$.

ADDENDUM

Here is a plot of 1,000,000 terms of the original series vs. 1000 terms of the new series representation with the log term. Here I plotted approximations of

$$f\left (1-10^{-x} \right ) $$

for $x\in [1,4]$.

enter image description here

The plot in red is the new series, while the plot in blue, with the discontinuity at $3.0$, is the original series. Clearly there is some problem with the original series; this is why I trust the new series.