I was trying to find out how to represent the sum of integers between two integers $a$ and $b$ as the area under a curve and this is the equation I came up with:
$$\int_{-a}^bx+\frac{1}{2}dx$$
or
$$\int_{a-\frac{1}{2}}^{b+\frac{1}{2}}xdx$$
So the triangle from $-\frac{1}{2}$ to $0$ and from $0$ to $b+\frac{1}{2}$ have areas that sum to the the sum of integers from $0$ to $b$:
$$\int_{-\frac{1}{2}}^{b+\frac{1}{2}}xdx=\sum_{n=0}^bn$$
Otherwise written as:
$$\int_{0}^{b+\frac{1}{2}}xdx -\frac{1}{8}=\sum_{n=0}^bn$$
Aside from these extensions of the idea, if theres any intuitive way to understand why the bounds have to be shifted by $\frac{1}{2}$ for this to work I would appreciate someone sharing.
Here's some intuition to it: Imagine each integer as having a box of width $1$ associated with it. The integral from $a$ to $b$ only has the upper half of $a$'s box and the lower half of $b$'s box, so the sum ends up smaller than it should be. By going down to $a - 1/2$ and $b + 1/2$, you include the full size of $a$ and $b$'s boxes.
This phenomenon shows up in statistics in the form of the continuity correction, in which approximations of discrete distributions by continuous ones have the limit of integration offset by $1/2$ in a similar fashion. Here, the box width analogy applies in that if you aren't including each integer's full box, you underweight its probability relative to the other outcomes.