Error of $\left(1+\frac{1}{n}\right)^n$ For a positive $\varepsilon$, how do you find $n$ that satisfies $e-\left(1+ \frac{1}{n}\right)^n<\varepsilon$?
Below is the context.
Definition
$$e=\lim_{n\rightarrow\infty}\left(1+ \frac{1}{n}\right)^n$$
Attempt
It is proved that $e=1+1+\frac{1}{2!}+\frac{1}{3!}+\dots$. On the other hand, $\left(1+ \frac{1}{n}\right)^n = 1+1+\left(1-\frac{1}{n}\right)\frac{1}{2!}+\left(1-\frac{1}{n}\right)\left(1-\frac{2}{n}\right)\frac{1}{3!}+\dots+\left(1-\frac{1}{n}\right)\dots\left(1-\frac{n-1}{n}\right)\frac{1}{n!}$.
So,
$$\begin{aligned}
e-\left(1+ \frac{1}{n}\right)^n &= \sum_{k=1}^n \left( 1 - \prod_{i=1}^k \left(1-\frac{i}{n}\right)\right)\frac{1}{(k+1)!} +r(n)\\
&<\sum_{k=1}^n \left( 1 - \left(1-\frac{k}{n}\right)^{k}\right)\frac{1}{(k+1)!} + r(n)
\end{aligned}$$
$r(n)$ can be evaluated using Taylor's theorem. The problem is to find $n$ which satisfies $\sum_{k=1}^n \left( 1 - \left(1-\frac{k}{n}\right)^{k}\right)\frac{1}{(k+1)!}<\varepsilon$.
Motivation and where the question comes from
This is a natural question. It is normal to evaluate the error for all limits.
My background
Undergraduate.
 A: Consider that you look for the solution of the equation
$$\left(1+\frac{1}{n}\right)^n=k$$
Let $x=1+\frac 1n$ to make
$$x^{\frac{1}{x-1}}=k$$ which is exactly in a suitable form for a solution in terms of Lambert function. If you follow the steps given in the "solving equations" section, you will get
$$x=-\frac{W_{-1}\left(-\frac{\log (k)}{k}\right)}{\log (k)}$$ Back to $n$
$$n=-\frac{\log (k)}{W_{-1}\left(-\frac{\log (k)}{k}\right)+\log (k)}$$ Now, using $k=e-\epsilon$ and considering that $\epsilon$ is small, we have
$$\log(k)=1-\frac{\epsilon }{e}-\frac{\epsilon ^2}{2 e^2}+O\left(\epsilon ^3\right)$$
$$\frac {\log(k)} k=\frac{1}{e}-\frac{\epsilon ^2}{2 e^3}+O\left(\epsilon ^3\right)$$
$$W_{-1}\left(-\frac{\log (k)}{k}\right)=-1-\frac{\epsilon }{e}-\frac{7 \epsilon ^2}{6 e^2}+O\left(\epsilon ^3\right)$$
So, as an approximation
$$n =\frac{e}{2 \epsilon }-\frac{11}{12}+O\left(\epsilon\right)$$
Trying for $\epsilon=10^{-6}$, this truncated series would give $\lceil n \rceil= 1359140$ while the exact solution, given by Newton method is ... identical.
Working with real numbers, the truncated series would give $1.3591399975628560\times 10^6$ to be compared to the exact
$1.3591399975628815\times 10^6$
A: This is an alternate way to derive an $n$ that works, reasonable close to the optimal one given in Claude Leibovici's answer, without using any special function.
Notice for $x > 0$,
$$\left(\frac1x\right)' = -\frac1{x^2} < 0\quad\text{ and }\quad \left(\frac1x\right)'' = \frac{2}{x^3} > 0$$
$\frac1x$ is strictly decreasing and strictly convex over $(0,\infty)$. This implies for any $n > 0$, its integral over $[n,n+1]$ is sandwiched between its values at lower end and midpoint. i.e
$$
\frac1n > \int_n^{n+1} \frac{dx}{x} = \log\left(1 + \frac1n\right) >\frac{1}{n+\frac12}$$
This is equivalent to
$$\left(1+\frac1n\right)^n < e < \left(1+\frac1n\right)^{n+\frac12}$$
From this, we can deduce
$$0 < e - \left(1+\frac1n\right)^n
< \left(1+\frac1n\right)^n\left(\sqrt{1+\frac1n}-1\right) < \frac{e}{2n}$$
This implies for any integer $n \ge \left\lceil \frac{e}{2\epsilon}\right\rceil$, we will have $0 < e - \left(1+\frac1n\right)^n < \epsilon$.
