7
$\begingroup$

If I calculate $e$ using the following formula.

$$e = \sum_{k=0}^{\infty}{\frac{1}{k!}}$$

Is it possible to predict how many correct decimal places I get when I stop summing at $n$ terms?

  • 1
    There is a subtlety in the contrast between "correct decimal places" and accuracy. Most of us had interpreted "$n$ correct decimal places as within $10^{-n}$, but as Dan Brumleve points out, you could be very close. If the correct answer is $1.9999$, an error of $10^{-4}$ can change the ones digit. Having a string of $9$'s is rare, but if you care about it you need to check.2012-11-10

5 Answers 5

14

If we use $n$ terms, the last term used is $\dfrac{1}{(n-1)!}$. The missing "tail" is therefore $$\frac{1}{n!}+\frac{1}{(n+1)!}+\frac{1}{(n+2)!}+\frac{1}{(n+3)!}\cdots.\tag{$1$}$$ Note that $(n+1)!=n!(n+1)$ and $(n+2)!\gt n!(n+1)^2$, and $(n+3)!\gt n!(n+1)^3$ and so on. So our tail $(1)$ is less than $$\frac{1}{n!}\left(1+\frac{1}{n+1}+\frac{1}{(n+1)^2}+\frac{1}{(n+1)^3}+\cdots \right).$$ Summing the geometric series, we find that the approximation error is less than $$\frac{1}{n!}\left(1+\frac{1}{n}\right).$$

  • 0
    This is a good answer, why was it downvoted?2012-11-09
  • 0
    The question asks for how many correct digits, not an upper bound on the error. On the other hand, in retrospect perhaps it was fair to assume that the OP is only looking for an approximate answer and isn't distinguishing between the two cases.2012-11-09
  • 4
    To end the error vs correct digits discussion: If you calculate $e_n:=\sum_{k=0}^n\frac1{n!}$ and $e_n+\frac1{n!}(1+\frac1n)$ and both agree on $d$ decimals, then both estimates are correct to (at least) $d$ decimals.2012-11-09
  • 0
    @Hagen, that looks right; I was reading the question to be asking for the exact number of correct leading digits given $n$, not just a lower bound.2012-11-09
  • 2
    @DanBrumleve How about instead of just downvoting (something that can't be undone after a few minutes) 10 (a slight exaggeration) different answers without a single comment (until after someone asked why), leave a comment and clarify. Then, if it turns out you misunderstood, you haven't just downvoted 10 different answers incorrectly.2012-11-09
  • 0
    @Graphth, downvotes can be undone after an edit. Because of how the question is worded I think a complete answer should at least mention the issue with the digits.2012-11-09
  • 2
    @DanBrumleve Well, obviously many other people (everyone who answered?) believe otherwise. So, is it possible that at the very least it's just your preference? And, if so, is it really worth downvoting?2012-11-09
  • 0
    @Graphth, it is just my preference.2012-11-09
  • 2
    @DanBrumleve While this is more of a meta issue, IMHO there is a difference between 'this is not how I would have answered the question' or even 'this is not what I consider a complete answer to the question' and 'this is an _unhelpful_ answer to the question' - I would consider the latter to be a minimal standard for downvoting (as opposed to simply not voting), and the FAQ seems to agree: 'Use your downvotes whenever you encounter an egregiously sloppy, no-effort-expended post, or an answer that is clearly and perhaps dangerously incorrect.' This answer is hardly egregious or dangerous.2012-11-10
  • 0
    @Steven, [I'm not so sure](http://www.cs.tau.ac.il/~nachumd/horror.html). But I sure hope no one is computing the $n$'th digit of $e$ by expanding the Taylor series for $e^x$ around $0$ at $x=1$ to some point determined by Stirling's formula.2012-11-10
5

You can use the remainder term in Taylor's expansion

  • 0
    To what function are we applying Taylor's theorem?2012-11-09
  • 0
    @robjohn the definition of $e$ given by OP is actually the Taylor series for $e^x$ centered at $x=0$, evaluated at $x=1$.2012-11-09
  • 0
    @Logan: As I mentioned in a comment to glebovg, since $f$ was not specified in the question, it would be good to mention it in the answer.2012-11-10
5

In this answer, it is shown, by comparison to a geometric series, that $$ 0\le n!\left(e-\sum_{k=0}^n\frac1{k!}\right)\le\frac1n $$ Therefore, the error after $n+1$ terms is at most $\frac1{nn!}$ .

To $n$ decimal places:

When asking for a number to $n$ decimal places, there are two common meanings

  1. the error is less than $\frac12\times10^{-n}$.

  2. the value is correct when rounded to $n$ decimal places. As has been pointed out, if a number is very close to $10^{-n}\left(\mathbb{Z}+\frac12\right)$, rounding to $n$ decimal places might require computing more decimal places to know the actual $n^{\mathrm{th}}$ digit of the rounded number. This is not as easy to use as meaning 1, so it is not as commonly used.

  • 0
    That was a fast downvote. Care to comment?2012-11-09
  • 0
    Is someone just downvoting for free?2012-11-10
  • 0
    @PeterTamaroff: nah... it still costs 1 rep to downvote an answer (afaik).2012-11-10
1

The series converges rapidly. If you stop at $\frac 1{ k!}$ you can bound the error by $\frac 1{k(k!)}$ by bounding the remaining terms with a geometric series.

  • 0
    Why was this downvoted? It seems a bit scant, but valid.2012-11-09
  • 0
    I downvoted for the same reason as most of the others: the question asks about the number of correct leading digits in the partial sum and this upper bound on the error term doesn't lead to any obvious answer to that question.2012-11-10
0

The $n$-th Taylor polynomial is $${P_n}(x) = f(0) + \frac{{f'(0)}}{{1!}}x + \frac{{f''(0)}}{{2!}}{x^2} + \cdots + \frac{{{f^{(n)}}(0)}}{{n!}}{x^n}$$ (in this case $f(x)$ is simply $e$) and the error we incur in approximating the value of $f(x)$ by $n$-th Taylor polynomial is exactly $$f(x) - {P_n}(x) + \frac{{{f^{(n + 1)}}(c)}}{{(n + 1)!}}{x^{n + 1}}$$ where $0 < c < x$. This form of the remainder can be used to find an upper bound on the error. If the difference above is positive, then the approximation is too low, and likewise if the error is negative, then the approximation is too high. We only need to find an appropriate $c$.

  • 0
    To what function are we applying Taylor's theorem?2012-11-09
  • 0
    @robjohn In this case $e^x$ for $x = 1$, but it works in general.2012-11-09
  • 0
    Why downvote? Please comment.2012-11-09
  • 0
    I downvoted because it doesn't address the distinction between the error term and the number of correct digits in the partial sum. (Also consider simplifying or clarifying: the question asks only about $e$ not $e^x$.)2012-11-09
  • 0
    @glebovg: Since $f$ was not specified in the question, it would be good to mention it in the answer.2012-11-09