Which value of $n$ do we need to take so that the displayed value of $e$, i.e., to 5 decimal places, be the correct (theoretical) one?


The function $(1+1/x)^x$ is increasing for $x$ positive, since its derivative has the sign of $\ln((x+1)/x)-1/(x+1)$ which is always positive since $(x+1)/x>1$ and $1>1/e^{x+1}$. The answer is then 743325 since:

\begin{align} \left(1+{1\over743\,324}\right)^{743\,324}&=2.718279999997650016053842\\ \left(1+{1\over743\,325}\right)^{743\,325}&=2.718280000000109854133239 \end{align}

as obtained by Mathematica to 25 decimal places. You would get different results down to machine precision, for instance, on wulfrun2:

julia> [(1+1/n)^n for n=743300:743330]
31-element Array{Float64,1}:
 2.7182799999663185
 2.7182800001374527
 2.7182799998501066
 2.718280000001561 
 2.718280000143176 
 2.7182799998263083
 2.7182799999482437
 2.7182800000603398
 2.7182800001625957
 2.718279999806367 
 2.7182799998889435
 2.7182799999616805
 2.718280000024578 
 2.718280000077636 
 2.7182800001208545
 2.718280000154233 
 2.7182800001777725
 2.718280000191472 
 2.7182800001953322
 2.718280000189353 
 2.718280000173534 
 2.7182800001478755
 2.7182800001123777
 2.71828000006704  
 2.718280000011863 
 2.7182799999468465
 2.7182799998719904
 2.7182799997872946
 2.7182800001414162
 2.718280000037042 
 2.7182799999228284

which not only is non-monotonic, i.e., it gets closer and farther away from the solution, or more accurately, increases and decreases (unlike what the derivative of $(1+1/x)^x$ tells you), but it also displays highly non-mathematical jumps:

Screenshot 20210208 162052.png

The exact solution, from Mathematica (in blue) is also much more accurate than the machine one (with Julia, in orange).

(back to the lecture)