Similar looking sum and integral for the same function I've recently become aware that if $f(x) = ax + b$, then
$$\sum_{i = 0}^nf(i) = \frac{1}{2}(n + 1)(an + 2b)$$
while
$$\int_{0}^{n}f(t)\,dt = \frac{1}{2} n(an + 2b).$$
These two look suspiciously similar to me. Is there something going on here or is it just a coincidence? Are there functions for which
$$\sum_{i = 0}^nf(i) = \int_{0}^{n}f(t)\,dt$$
for all $n \in \mathbb{N}$?
 A: Hint. Draw pictures that illustrate the two areas: one a triangle, one a sequence of rectangles. Just the case $a = b= 1$ should be instructive.
A: One choice is to start with $f(0)=0$, then have $f(x)$ constant for $x \gt 0$  Another is to define $g(x)$ as any integrable function on $[0,\infty)$, then choose $f(x)=g(x)$ for $x \not \in \Bbb Z$ and choose $f$ on the integers to make the sum come out equal to the integral.  Changing the value of a function at points does not change the integral.
A: $$f(x)=ax+b$$
$$\begin{align}\sum_{i=0}^nf(i)=&a\sum_{i=0}^ni+b\sum_{i=0}^n1\\
=&a\frac{n(n+1)}{2}+b(n+1)\\
=&\frac12(n+1)\left(an+2b\right)\end{align}$$

$$\begin{align}\int_0^nf(x)\,\mathrm dx=&\int_0^n(ax+b)\,\mathrm dx\\
=&\left[\frac a2x^2+bx\right]_0^n\\
=&\frac12n(an+2b)\end{align}$$

An integral can be thought of as an infinite sum of finite area elements to give the total area. It might be easier to split this into two pieces:
$$\int_0^nf(x)\,\mathrm dx=\lim_{k\to\infty}\sum_{i=1}^kf(x^*_i)\Delta x_i$$
where you can take upper, lower and middle Riemann sums. You might want to try this for yourself using all three. You can think of $\Delta x_i$ as a discrete $\mathrm dx$ and it is going to be equally divided, each "strip" having a width of the domain divided by the number of strips, so:
$$\Delta x_i=\frac nk$$
and obviously $f(x_i)$ is going to vary depending on where within the strip we take the value, I would recommend reading into Riemann integrals and sums as this will explain what you are looking for, here's a video. And here is the wiki page.

PS sorry for the rushed answer I have ran out of time
