# Area between Curves

Now, when we know what definite integral is, we can calculate area between curves.

Consider the region `S` that lies between two curves `y=f(x)` and `y=g(x)` and between the vertical lines `x=a` and `x=b`, where `f` and `g` are continuous functions and `f(x)>=g(x)` for all `x` in `[a,b]`.

We will proceed in the same fashion as we did when talked about area problem.

Divide region into `n` strips of wdith `Delta x=(b-a)/n`. We approximate i-th strip by rectangle with base `Delta x` and height `f(x_i^(**))-g(x_i^(**))` where `x_i^(**) in [x_(i-1),x_i]`. Thus, approximate area is defined by Riemann sum as `A~~sum_(i=1)^n(f(x_i^(**))-g(x_i^(**)))Delta x` . As `n` becomes larger, approximation becomes better.

Therefore, we define area A of S as the limiting value of the sum of the areas of these approximating rectangles: `A=lim_(n->oo)sum_(i=1)^n(f(x_i^(**))-g(x_i^(**)))Delta x` .

We recognize in limit definite integral of `f-g`.

**Formula for Area between Curves**. The area `A` of the region bounded by the curves `y=f(x)` and `y=g(x)`, and the lines `x=a`, `x=b`, where `f` and `g` are continuous functions and `f(x)>=g(x)` for all `x` in `[a,b]` is `A=int_a^b (f(x)-g(x))dx`.

Indeed, we know that if `f` is positive then area under function `f(x)` and above x-axis on `[a,b]` is `int_a^b f(x)dx`. In case `f(x)` is negative, area above function `f(x)` and below x-axis is again `int_a^b f(x)dx`. Similarly for function `g`. Thus, area between curves is area "enclosed" by `f(x)` minus area "enclosed" by `g(x)`: `A=int_a^b f(x)dx-int_a^bg(x)dx=int_a^b (f(x)-g(x))dx`.

Note that if `g(x)=0`, then `A=int_a^bf(x)dx` is area under the graph of `f` and above x-axis.

Sometimes it is more easier to treat `x` as a function of `y`. In this case we do the same thing except we strip region by parallel to x-axis lines (not perpendicular as in case where `y` is a function of `x`) and obtain following formula.

**Formula for Area between Curves when `x` is a function of `y`**. The area `A` of the region bounded by the curves `x=f(y)` and `x=g(y)`, and the lines `x=c`, `y=d`, where `f` and `g` are continuous functions and `f(y)>=g(y)` for all `y` in `[c,d]` is `A=int_c^d (f(y)-g(y))dx`.

**Example 1**. Find the area of the region bounded above by `y=sqrt(x+2)` , bounded below by `y=1/(x+1)` , and bounded on the sides by `x=0` and `x=2`.

The upper boundary curve is `f(x)=sqrt(x+2)` and the lower boundary curve is `y=1/(x+1)`. Therefore, `A=int_0^2 (sqrt(x+2)-1/(x+1))dx=(2/3(x+2)^(3/2)-ln(x+1))|_0^2=`

`=(2/3*8-ln(3))-(2/3 2^(3/2)-ln(1))=16/3-4/3sqrt(8)-ln(3)`.

Now let's see how to handle situations when we are not given limits for integration.

**Example 2**. Find the area of the region enclosed by the parabola `y=5x-x^2` and line `y=x`.

We are not given points bounds of integration here, so we need to find them.

For this need to find points of intersections of curves. To do this we must solve system

`{(y=5x-x^2),(y=x):}`.

From this `5x-x^2=x` or `x(x-4)=0`. Solutions are `x=0` and `x=4`. Thus, points of intersection are (0,0) and (4,4)

Top boundary curve is `y=5x-x^2` and lower boundary curve is `y=x`. Therefore, `A=int_0^4 ((5x-x^2)-x)dx=int_0^4(4x-x^2)dx=(2x^2-1/3 x^3)|_0^4=`

`=(2*4^2-1/3*4^3)=32-64/3=32/3`.

Now, let's see in what situations we need to split interval of integration into parts.

**Example 3**. Find the area of the region enclosed by `y=5x-x^2` and `y=x` on interval `[-1,5]`.

This example is extension of example 2. We encounter here problem. Function `f(x)=5x-x^2` is not greater than `g(x)=x` on interval `[-1,5]`.

To solve this problem we must divide interval `[-1,5]` on subintervals where `f(x)>=g(x)` and where `g(x)>=f(x)`.

First subinterval is `[-1,0]`: here `f(x)<=g(x)` so `A_1=int_(-1)^0(x-(5x-x^2))dx=`

`=int_(-1)^0 (x^2-4x)dx=(1/3 x^3-2x^2)|_(-1)^0=-(-1/3-2)=7/3`.

Second subinterval is `[0,4]`: here `f(x)>=g(x)` and we found area of this region in example 2, so `A_2=32/3`.

Third subinterval is `[4,5]`: here again `f(x)>=g(x)` so `A_1=int_4^5(x-(5x-x^2))dx=int_4^5 (x^2-4x)dx=(1/3 x^3-2x^2)|_4^5=`

`=(1/3*5^3-2*5^2)-(1/3*4^3-2*4^2)=7/3`.

Finally total area is `A=7/3+32/3+7/3=46/3`.

Following example shows that sometimes it is better to treat function as function of `y` rather than `x`.

**Example 4**. Find the area enclosed by the line `y=x+1` and parabola `y^2=2x+5`.

Here the first problem is that on different intervals we have different lower bounds. The other problem that we need express `y` from `y^2=2x+6`. We obtain 2 curves: `y=+-sqrt(2x+5)`. This adds work to find area.

So, it is better to use formula when `x` is a function of `y`.

But for educational purposes let's do it in two ways.

First find points of intersection:

`{(y=x+1 ),(y^2=2x+5):}`

Or `(x+1)^2=2x+5`. From this we have that `x^2=4`. Solving this equation we obtain that `x=+-2`.

Thus, points of intersection are (-2,-1) and (2,3).

Also, point where `y=0` for curve `y^2=2x+5` is `x=-5/2`.

Let's first solve regarding `y` as a function of `x` . This will show the two problems we talked about.

First problem is that `y^2=2x+5` or `y=+-sqrt(2x+5)`. This gives two curves.

Second problem is that we can't integrate directly. We must divide required area into two areas: green area and yellow area, because there are different lower boundary curves:

For green area lower boundary curve is `-sqrt(2x+5)` , so `A_1=int_(-5/2)^(-2)(sqrt(2x+5)-(-sqrt(2x+5)))dx=2int_(-5/2)^(-2)sqrt(2x+5)dx=2/3(2x+5)^(3/2)|_(-5/2)^(-2)=`

`=2/3*1=2/3`.

For yellow area lower boundary curve is `y=x+1` , so `A_2=int_(-2)^(2)(sqrt(2x+5)-(x+1))dx=int_(-2)^2 (sqrt(2x+5)-x-1)dx=(1/3(2x+5)^(3/2)-1/2x^2-x)|_(-2)^2=`

`=9-2-2-(1/3-2+2)=14/3`.

Therefore, `A=A_1+A_2=2/3+14/3=16/3`.

If we now treat `x` as function of `y` then equations of curves are: `x=y-1` and `x=1/2(y^2-5)`, bounds for `y` are from -1 to 3 so`A=int_(-1)^3(y-1-1/2(y^2-5))dy=(1/2y^2-1/6y^3+3/2y)|_(-1)^3=9/2-9/2+9/2-(1/2+1/6-3/2)=16/3`.

As can be seen second method is much easier.