# Evaluating the precision in the calculation of $\mathrm{e}$

I'm calculating $\mathrm{e}$ using a computer like this: $$\mathrm{e} \approx \sum\limits_{i=0}^n {1\over i!}$$ I'm storing it as a rational number.

I was wondering, if I write down my rational number as a decimal number, could I determine, how many digits after the decimal point are correct for a given value of $n$?

-
You need $\displaystyle\sum_{i=0}^\infty$, starting with $i=0$, not with $i=1$, and going to $\infty$, not to $n$. Also, the fraction should be $\dfrac{1}{i!}$, not $\dfrac{1}{n!}$. – Michael Hardy Dec 29 '13 at 23:30
@MichaelHardy I think the $n$ on top is what the OP wants. He should have written $\approx$ instead of $=$. – Git Gud Dec 29 '13 at 23:32
@GitGud : If so, then it should not say "$=$". ${}\qquad{}$ – Michael Hardy Dec 29 '13 at 23:45
Unrelated but potentially useful to the OP: using the continued fraction expansion for $\exp(z)$ is more accurate, and if you compute the convergents $A_{n}$, $B_{n}$ recursively...it is faster since it uses fewer division operations... – Alex Nelson Dec 30 '13 at 0:37
@user21820 Well, look at (e.g.) Wikipedia's page for the general formulas for the numerator and denominator. You can compute them recursively, requiring (for each iteration) 2 additions and 4 multiplications. So $N$ iterations costs 1 division operation (the final division) + $2N$ addition + $4N$ multiplication, far better than the naive Taylor series. – Alex Nelson Dec 30 '13 at 14:41

Using the Taylor remainder formula you get that, for some $\xi\in (0,1)$ $$0<\mathrm{e}-\sum_{i=0}^n\frac{1}{n!}=\frac{\mathrm{e}^\xi}{(n+1)!}<\frac{3}{(n+1)!}.$$ Thus the error is less than $\frac{3}{(n+1)!}$.

-
This is definitely not the simplest way. It relies, for example, on the mean value theorem. – Michael Hardy Dec 29 '13 at 23:41

As yet another possibility, if you calculate $$\frac1e = \sum_{i=0}^\infty \frac{(-1)^i}{i!}$$ then you have an alternating series, so the true value of $1/e$ is strictly between any two successive partial sums, which you can then invert and represent in decimal. Any digits they agree on are certain.

-

The tail of the series is bounded above by a geometric series: \begin{align} \sum_{i=n+1}^\infty \frac{1}{i!} \le \frac{1}{(n+1)!}\sum_{i=0}^\infty \frac{1}{(n+1)^i}. \end{align}

It's easy to find the sum of that series, so you get an upper bound on $e$.

The lower bound comes from stopping after finitely many terms.

-

Since the factorials grow so fast, the first term you ignore is a very good estimate for the error. So if you sum up through $n=10$, the first ignored term is $\frac 1{11!}\approx 2.5\cdot 10^{-8}$ The next is a factor $12$ smaller, so using the first as your error estimate is pretty good.

-