\section{Integration in Two Real Variables}

\subsection{Iterated Integrals in Two Variables}

In order to actually compute integrals in two variables, we will write them as iterated integrals and then use antiderivatives. The easiest case is when the region of integration is a rectangle. Here is another theorem that we will not prove (a special case of Fubini's Theorem).

\begin{theorem}\label{Fubini-thm}
Let $f(x,y)$ be a bounded function on a closed and bounded rectangle $D= \{(x,y) \in \mathbb{R}^2 :\ a \leq x \leq b,\  c \leq y \leq d\}$. Assume that $f$ is integrable on $D$. Then
$$
\iint_D f(x,y)dA=\int_a^b \left(\int_c^d f(x,y)dy\right) dx
=\int_c^d\left( \int_a^b f(x,y)dx\right) dy.
$$
\end{theorem}


\begin{figure}[H]
\centering
\includegraphics[width = .50\linewidth]{51fig6.pdf}
\caption{If the region of integration is a rectangle, we can arrange the order of summation in Riemann sums in either one of the two ways shown here. }\label{51fig6}
\end{figure}





Intuitively, if we think about the double integral as being approximated by 
Riemann sums, then the two iterated integrals correspond to the two orders of summation shown in Figure \ref{51fig6}.

When the region of integration is not a rectangle, it may still be possible to write the region of integration in one of the two ways shown in Figure \ref{51fig5}.


\begin{figure}[h]
\centering
\includegraphics[width = .55\linewidth]{51fig5.pdf}
\caption{Two cases of sets $D$ where the range of the $x$ and/or $y$ coordinates can be written as functions of the other variable.}\label{51fig5}
\end{figure}

 




Suppose $D$ is $y$-simple as defined in Figure \ref{51fig5}, $f$ is continuous on $D$, and $c(x)$ and $d(x)$ are continuous on the interval $[a,b]$. Then, we write the iterated (double) integral of $f(x,y)$ over $D$ as
$$
\iint_D f(x,y) dA = \int_a^b \bigg[\int_{c(x)}^{d(x)} f(x,y) dy \bigg] dx.
$$
Of course, we have a similar expression when $D$ is $x$-simple, with the $x$ and $y$ variables interchanged. We always perform summation in the simple direction first.
 If $D$ is both $x$-simple and $y$-simple, we can choose whichever order we prefer.  
 
 
 
\subsection{Applications of Double Integrals} Let $D \subset \mathbb{R}^2$ be a bounded region, and let $f(x,y)$ be a function defined and bounded on $D$. We assume that both $f$ and $D$ are nice enough so that the integral $\iint_D f\,dA$ exists (see Section 5.1 for sufficient conditions).

One basic application is as follows:


\begin{equation}\label{eq:area}
\iint_{D} 1 d A = (\textrm{area of } D).
\end{equation}

For an explanation, you may want to revisit the notes on Jordan area in Section 5.1. The upper and lower approximations, $S^*$ and $S_*$, to the area of a bounded planar region $X$ are actually Riemann sums for the function $f(x,y)$ that is equal to $1$ on $X$ and $0$ on its complement. (This is often called the \textit{characteristic function} or \textit{indicator function} of $X$.) Both the Jordan area of $X$ and the integral $\iint_X fdA$ are defined as the limit of such sums as the partition diameter goes to $0$.


We can use double integrals to evaluate volumes under graphs of functions of two variables. If $f(x,y) \geq 0$ for all $(x,y) \in D$, then 
\begin{equation}\label{eq:volume}
\iint_{D} f(x,y) d A = \textrm{ (volume under the graph of } z = f(x,y) \textrm{ above } D).
\end{equation}
Here, by ``\textit{above} $D$", we mean above $D$ when $D$ is viewed as a subset of the plane $z = 0$ in $\mathbb{R}^3$. This is similar to the interpretation of an integral $\int_a^b f(x)dx$ of a nonnegative function $f(x)$ as the area under its graph. See Worked Problem 5 for an example. 

We also use integrals to calculate averages of functions. If the region $D \subset \mathbb{R}^2$ has finite area, then


\begin{equation}\label{eq:average}
\textrm{(Average value of } f(x,y) \textrm{ on } D) = \frac{\iint_{D} f(x,y) d A}{\textrm{Area of } D}.
\end{equation}

As a \underline{special case} of the average value formula, if $D \subset \mathbb{R}^2$ is a region, then the \textbf{centroid} of $D$ is the point $(\bar{x}, \bar{y}) \in \mathbb{R}^2$ where
$$
\bar{x} : = \frac{\iint_{D} x d A}{\textrm{Area of } D} \quad \quad \bar{y} : = \frac{\iint_{D} y d A}{\textrm{Area of } D}.
$$

\smallskip
In words, the centroid encodes the average values of the $x$ and $y$ coordinates on $D$. (Note that the centroid is not always a point of $D$.)

 
 
 
 

 
 
\section*{Worked Problems}

\begin{enumerate}[1.]
\item{\it Let $D : = \{(x,y) : 0 \leq x \leq 2, 0 \leq y \leq 3 \}$.  Evaluate the integral of $f(x,y) = x^2y$ over $D$.}

\medskip
We evaluate the integral of $f(x,y)$ over $D$ as an iterated integral. Here, $D$ is a rectangle, therefore both $x$-simple and $y$-simple. In this example, the order of integration does not make much difference.
\smallskip

\begin{eqnarray*}
\iint_{D} x^2 y \,dA & = & \int_0^2 \int_0^3 x^2 y dy dx = \int_0^2 \frac{x^2 y^2}{2}\Big\vert_{y = 0}^{y = 3} dx \\
\quad & = & \int_0^2 \frac{9}{2} x^2 dx = \frac{3}{2} x^3 \Big\vert_0^2 \\
\quad & = & 12
\end{eqnarray*}

\bigskip

\item{\it Find the integral of $f(x,y) = x^2 y$ on $D : = \{(x,y) : 0 \leq x \leq 1, 0 \leq y \leq x\}$.}

\medskip
The region $D \subset \mathbb{R}^2$ is a right triangle with vertices $(0,0)$, $(1,0)$ and $(1,1)$.  

\begin{figure}[H]
\centering
\includegraphics[width = .25\linewidth]{51fig7.png}
\caption{The triangle with vertices $(0,0)$, $(1,0)$ and $(1,1)$.}\label{51fig7}
\end{figure}

This is, again, both an $x$-simple and a $y$-simple region. If we follow the $y$-simple order of integration, we see that $y = y(x) = x$ at the upper boundary of $D$ and $y = y(x) = 0$ at the lower boundary.
Evaluating as an iterated integral then gives
\begin{eqnarray*}
\iint_D x^2 y dA & = & \int_0^1 \int_0^x x^2 y dy dx = \int_0^1 \frac{x^2 y^2}{2} \Big\vert_0^x dx \\
\quad & = & \int_0^1 \frac{x^4}{2} dx = \frac{x^5}{10} \Big\vert_0^1 \\
\quad & =& 10
\end{eqnarray*}

\item{\it Find the integral of $f(x,y) = y$ on $D = \{(x,y) : 0 \leq x \leq 1, 0 \leq y \leq x^2 \}$. }

\medskip
We again evaluate this integral on $D$ as a $y$-simple domain.
\begin{eqnarray*}
\iint_D y d A & = & \int_0^1 \bigg[\int_0^{x^2} y dy \bigg] dx = \int_0^1 \frac{y^2}{2} \Big\vert_0^{x^2} dx = \int_0^1 \frac{x^4}{2} dx = \frac{x^5}{10}\Big\vert_0^1 \\
\quad & = & \frac{1}{10}
\end{eqnarray*}

\bigskip

\item{\it Find the integral of $f(x,y) = 3y$ over the region $D$, where $D$ is the region bounded by the curves $xy^2 = 1$, $y = x$, $x=0$ and $y=3$.}

\medskip
The region $D$ is slightly more complicated than those in the previous examples.  We give a picture in Figure \ref{51fig9}.

\begin{figure}[H]
\centering
\includegraphics[width = .20\linewidth]{51fig9.png}
\caption{The region $D$ in Worked Problem 4.}
\label{51fig9}
\end{figure}

Notice that the curves $y = x$ and $xy^2 = 1$ intersect at the point $(x,y) = (1,1)$.  Moreover, if we split the region $D$ as
$
D = D_1 \cup D_2
$
where $D_1$ contains the part of $D_1$ below the line $y = 1$ and $D_2$ contains the part above,  we see that $D_1$ and $D_2$ are both $x$-simple. Importantly, they are also disjoint except for boundary, so that we can just add up the integrals. 
This allows us to evaluate the area integral as
$$
\iint_{D} 3y dA = \iint_{D_1} 3y dA + \iint_{D_2} 3 y dA.
$$
Evaluating each integral separately, we have
$$
\iint_{D_1} 3y dA = \int_0^1 \int_0^y 3 y dx dy = \int_0^1 3y^2 dy = y^3 \vert_0^1 = 1
$$
and then
$$
\iint_{D_2} 3 y dA = \int_{1}^3 \int_0^{y^{-2}} 3 y dx dy = \int_1^3 \frac{3}{y} dy = 3 \ln y \vert_{1}^{3} = 3 \ln 3
$$
Summing together, we have
$$
\iint_{D} 3y dA = 1 + 3 \ln 3.
$$





\item{\it Find the volume above the square $D = [-1,1]^2$ and below the paraboloid $z = 4-x^2 - y^2$.}



\begin{figure}[h]
\centering
\includegraphics[width = .5\linewidth]{52fig1}
\caption{The region $D$ in the $xy$-plane, and the 3-dimensional region above $D$ and below the paraboloid.}
\label{52fig1}
\end{figure}

\medskip

Figure \ref{52fig1} shows a rough diagram illustrating the region $D \subset \mathbb{R}^2$ (which we view as a subset of the plane $z = 0$ in $\mathbb{R}^3$) and the portion of the paraboloid above $D$.  The volume of this region can be written as the iterated integral
\begin{eqnarray*}
\iint_{D} 4 - x^2 - y^2 dA = \int_{-1}^{1} \int_{-1}^{1} (4 - x^2 - y^2) dx d y,
\end{eqnarray*}
which, by using the symmetry of the surface, we evaluate as
\begin{eqnarray*}
4 \int_{0}^1 \int_0^1 (4 - x^2 - y^2) dx dy & = & 4 \int_0^1 \bigg[4x - \frac{x^3}{3} - y^2 x \bigg]_{x = 0}^{1} dy \\
\quad & = & 4 \int_0^1 (\frac{11}{3} - y^2) dy = 4 \bigg[\frac{11}{3} y - \frac{y^3}{3} \bigg]_{0}^1 \\
\quad & = & \frac{40}{3}.
\end{eqnarray*}
Therefore, we have:
$$
\textrm{Volume } = \iint_{D} (4 - x^2 - y^2) dx dy = \frac{40}{3}.
$$

\bigskip


\item{\it Find the volume above the triangle with vertices $(0,0)$, $(0,1)$ and $(1,0)$ and under the plane $z = 2x + y$. }

\medskip


\begin{figure}[h]
\centering
\includegraphics[width = .5\linewidth]{52fig2.pdf}
\caption{The triangle with vertices $(0,0)$, $(0,1)$ and $(1,0)$}\label{52fig2}
\end{figure}


\medskip
The triangular region $D$ is shown in Figure \ref{52fig2}.
We evaluate the volume as the following iterated integral
$$
\iint_{D} (2x + y) d A = \int_0^1 dx \int_0^{1 -x} (2x + y) dy.
$$
Note that we wrote the $dx$ variable in front of the $dy$ integral--this is just another way of writing double integrals you will likely encounter. We then calculate 
\begin{eqnarray*}
 \int_0^1 dx \int_0^{1 -x} (2x + y) dy & = & \int_0^1 \bigg[2xy - \frac{y^2}{2} \bigg]_{y = 0}^{1-x} = \int_0^1 \bigg[2x (1 - x) + \frac{(1 -x)^2}{2} \bigg] dx \\
 \quad & = & \int_0^1 \bigg[-\frac{3x^2}{2} + x + \frac{1}{2} \bigg] dx = \bigg[- \frac{x^3}{2} + \frac{x^2}{2} + \frac{x}{2}\bigg]_{x=0}^1 \\
 \quad & = & \frac{1}{2}.
\end{eqnarray*}
So, the volume enclosed by this triangular region and the given plane is $\frac{1}{2}$.

\medskip

\item{\it Find the average value $f(x,y) = x \sin (x+y)$ on the rectangle $D : = \{(x,y) : 0 \leq x \leq 1, 0 \leq y \leq \pi\}$.}

\medskip

We use the averaging formula in \eqref{eq:average}.  We first find the area of the region, which is $1 \cdot \pi = \pi$.  We then evaluate the integral of $f(x,y)$ over $D$ as the iterated integral
$$
\iint_{D} f(x,y) d A = \int_0^1 \int_0^{\pi} x \sin (x+y) dy dx
$$
The calculation is
\begin{eqnarray*}
\int_0^1 \int_0^{\pi} x \sin (x+y) dy dx & = & \int_0^1 x \bigg(- \cos (x + y) \bigg)\big\vert_{y=0}^{\pi} dx \\
& = & \int_0^1 x \big( \cos x - \cos (\pi + x) \big) dx \\
\quad & = & \int_0^1 2x \cos x dx
\end{eqnarray*}
At the last step of the above calculation, we used that $\cos (\pi + x) = - \cos (x)$ for any real-number $x$. Therefore
$$
\iint_{D} f(x,y) dA = \int_0^1 2x \cos (x) dx = 2 \sin (1) + 2 \cos (1) - 2,
$$
where the last equality is obtained via integration by parts.  (Exercise: complete the calculations!) Hence, from the average formula \eqref{eq:average}, we have
$$
\textrm{Average of } f(x,y) \textrm{ on } D = \frac{2}{\pi}(\sin (1) + \cos (1) - 1)
$$

\medskip





\end{enumerate}












\section*{Practice Problems}
\begin{enumerate}[1.]
\item {Evaluate the integral 
$\displaystyle{\iint_D 3 dA}$, if $D$ is the region bounded by the parabola
$y^2-x-5=0$ and the line $x+2y=3$.  }

\bigskip

\item 
{Reverse the
order of integration to evaluate the following integrals. (In this question, the functions to be integrated (such as $\sin(y^3)$) do not have antiderivatives that could be written in terms of elementary functions. The only way to evaluate the integrals is to interchange the order of integration and then take advantage of the additional factors from integrating in $x$.)}



\medskip

(a) $\int_0^1 \int_{\sqrt{x}}^1 \cos(y^3+1) dydx.$


\medskip
(b) $\displaystyle{\int_0^1 \int_{x^2}^1  x^3\sin(y^3) dydx}$.


\bigskip


\item
Change the order of integration in the integral
$$
\int_0^4 \int_{x/2}^x \cos(y^2) \, dy\, dx
+ \int_4^8 \int_{x/2}^4 \cos(y^2) \, dy\, dx.
$$
Then evaluate the integral.



\bigskip


\item {Evaluate the double integrals. Use any method you like.

\medskip

(a)
$\displaystyle \iint_D y\, dA$,  $D$ is the triangle in the $xy$-plane with vertices $(0,0)$, $(1,2)$, $(3,0)$.}

\medskip


(b)  $\int_1^2 \int_{1/x}^1 ye^{xy} dydx$


\bigskip

\item {Find the volume under the plane $z=x$ and above the region in the $xy$-plane
bounded by $y=x$ and $y=x^2-x$.}

\bigskip



\item{Evaluate the double integral $\displaystyle \iint_D x\, dA$, where $D$ is the triangle with vertices $(0,0)$, $(2,1)$, $(4,0)$.}

\bigskip

\item{ Let $T$ be the triangle with vertices $(0,0)$, $(s,0)$ and $(s,t)$ for some $s,t > 0$.  Determine the centroid of $T$.}


\end{enumerate}




