# Calculus

## Area under a curve

Give a function $$f(x)$$ where $$f(x)\geq 0$$  over an interval $$a\leq x \leq b$$, we investigate the area of the region that is under the graph of $$f(x)$$ and above the interval $$[a,b]$$ on the x-axis. For example, the purple shaded region is the region above the x-axis from $$[-1,10]$$ and below the graph of a function $$f$$. Such an area is often referred to as the area under a curve.

However, since the area involves different curves with different arcs, it is difficult to calculate the area. However, if we think of the area as a series of rectangles, we can start to approximate the area.

Let's divide the interval $$[a,b]$$ into $$n$$ subintervals of length $$\Delta x$$ (where $$\Delta x$$  must be $$\frac{b-a}{n}$$). We label the endpoints of the subintervals by $$x_0, x_1, \ldots$$ with the start of the interval as $$a=x_0$$ and the end of the interval as $$b=x_n$$.

Notice $$\Delta x$$ becomes the width of each rectangle, and the height of each rectangle is defined by $$f(x)$$ at the beginning of each subinterval. So we can find the area of each rectangle by multiplying the height $$f(x)$$ by the width $$\Delta x$$. There are four subintervals in the diagram and 5 endpoints ($$x_n$$). So there is one less rectangle then the number of endpoints. If we let represent the number of rectangles, we can estimate the above area by adding the area of rectangles.

$Area \,of\,rectangles=\sum\limits_{i=0}^{n-1} f(x_i)\Delta x$

The above process is what we call a Riemann sum.

## Riemann Sum

The Riemann sum is only an appoximation to the actual area under the curve of the function $$f$$. However, we can improve the approximation by increasing the number of subintervals n, which decreases the width $$\Delta x$$ of each rectangle.

Continuing to increase $$n$$ is the concept we know as a limit as $$n\to\infty$$.

We can then approximate the area under the curve $$A_n$$ as

$A_n = \lim_{n\to\infty} \sum\limits_{i=0}^{n-1} f(x_i)\Delta x$

The above limit is also what we call the definite integral of $$f$$ from $$a$$ to $$b$$.

Play around with the different sliders, and try changing the function too.

Notice that as you increase n, the number of rectangles increases. As the number of rectangles increases, the approximation by the Reimann sum approaches the actual curve.