I was working on a computer programming project that involves 2D drawing on windows OS. I was displaying curves using simple mathematical formulas, and was thinking of filling the part under a curve.
That requires to draw straight lines from x to y. Then I was thinking, summing up those lines make up the area under the curve, which is clearly what an integral in mathematics is, but I was not able to explain one thing.
The length of those lines is the corresponding y's, so basically I would be summing: y1 + y2 + y3 + ...
So, if I have a graph for y = x, the sum is:
1 + 2 + 3 + . . .
The formula for this sum is clearly ((x * x) + x) / 2, and not (x * x) / 2.
I don't get it, because the laws of integration tell us that the integral of x^n is (x ^ (n+1)) / (n+1). How is that so?
Perhaps this figure will help you
What you're doing is the adding heights of the vertical blue lines on the left, which is clearly not the area under the blue curve!
Imagine you divide the interval $[0, x]$ into $N$ pieces each of size
$$ \Delta = \frac{x}{N} $$
The $x$ coordinates of each rectangle on the right figure can be labeled with the number $x_i = \Delta i$. The area of each individual rectangle is
$$ A_i = (x_{i + 1} - x_i) y_i = \Delta x_i = \Delta^2 i $$
So that the total area is
$$ A_N = \sum_{i=1}^N A_i = \sum_{i=1}^N \Delta x_i = \frac{x^2}{N^2} \sum_{i=1}^N i = \frac{x^2}{N^2}\frac{N(N+1)}{2} = \frac{x^2}{2} \left(1 + \color{blue}{\frac{1}{N}}\right) \tag{1} $$
Look at the term $\color{blue}{1/N}$, the larger the number $N$ the smaller $1/N$. In the limit when $N\to\infty$ this number is zero, and the area converges to
$$ \lim_{N\to\infty}A_N = A = \frac{x^2}{2} \tag{2} $$