When does the limit of a sum become an integral? In many maths and physics texts and courses, I've been told in many cases that the limit of a sum becomes an integral, i.e. (very roughly):
$$\lim_{n\to\infty} \sum_{x=0}^n f(x) = \int_0^\infty f(x) dx$$
However I know that this equation can't be true in every case, otherwise series would not exist. So I'd like to ask: what characteristics does $f(x)$ have for the above equation to be true?
More details:
Yesterday I had to resolve a series like this:
$$\lim_{n\to\infty} \sum_{x=0}^n (1 - e^{1/n}) e^{(n-x)/n}$$
This comes from a real-life problem. I decided to find the value of that limit using the following integral:
$$\lim_{n\to\infty} \int_0^n (1 - e^{1/n}) e^{(n-x)/n} dx$$
The reasons why I decided to go with the integral are two: habit and because I needed the sum to be continuous (meaning: every value summed must be infinitesimal). Also, I've always been told that sums are for discrete values, integrals are for continuous/infinitesimal ones.
The problem is that I do not have a mathematical justification for that. And while testing shows that the result matches reality, I don't know whether it is mathematically correct, or it is just a coincidence. So I asked myself: why should my limit be an integral and not a series?
I decided to calculate first the expression of $\sum_{x=0}^n (1-e^{1/n}) e^{(n-x)/n}$ (which is $1 - e^{1/n+1}$) and afterwards the limit for $n$ to infinity ($1  - e$). The result is the same of the integral, and I'm a bit surprised by that.
The reason why I'm surprised can be explained looking at the picture on this answer. My sum is not an area, however it it were, I'd know for sure that what I need is the picture on the left rather than the one on the right (being a real-life problem, I know in advance the nature of the operands I'm dealing with).
What's going on here? Which of the following equations is the most correct?
$$
\lim_{n\to\infty} \sum_{x=0}^n (1 - e^{1/n}) e^{(n-x)/n} = \lim_{n\to\infty} \int_0^n (1 - e^{1/n}) e^{(n-x)/n} dx \\
\lim_{n\to\infty} \sum_{x=0}^n (1 - e^{1/n}) e^{(n-x)/n} = \sum_{x=0}^n (1-e^{1/n}) e^{(n-x)/n}
$$
What I'm really interested in knowing: when do I need to transform a limit of a sum into an integral? And: does it happens every time that, when a limit of a sum is equal to an integral, the corresponding series have the same result?
 A: When you look up the definition of the Riemann integral (http://en.wikipedia.org/wiki/Riemann_integral#Riemann_sums), you will find that it is the limit of a sequence of sums. The same holds for the Lebesgue integral.
Update
Now I looked properly at the remainder of your question.
If you think about your sum, you are actually computing an integral over [0,1], approximated by points $x/n$ for $x = 0, ..., n$.
Also note that, for large $n$, $(1-e^{1/n}) \approx -1/n$.
So let's rewrite
\begin{align*}
\sum_{x=0}^n (1-e^{1/n}) e^{(n-x)/n} & \approx - \sum_{x=0}^n e^{1-x/n} \frac 1 n 
\approx - \int_0^1 e^{1-\xi} \ d \xi = 1 - e
\end{align*}
A: Indeed, it's ( any way, check the Riemann stuff… )
\begin{align}
&\lim_{n\to\infty} \sum_{x=0}^n (1 - e^{1/n}) e^{(n-x)/n} = \lim_{n\to\infty} \color{#ff0000}{n}\int_0^\color{#ff0000}{1} (1 - e^{1/n}) e^{(n-\color{#ff0000}{n}x)/n} dx 
=
{\rm e}\lim_{n \to \infty}{1 - e^{1/n} \over 1/n}\int_{0}^{1}{\rm e}^{-x}\,{\rm d}x
\\&=
{\rm e}\left(-1\right)\left(-{\rm e} + 1\right)
=
{\rm e}\left({\rm e} - 1\right)
\end{align}
