\documentclass[a4paper,12pt]{article}
\newcommand{\ds}{\displaystyle}
\usepackage{epsfig}
\begin{document}
\parindent=0pt

\begin{center}
\textbf{Applications of Partial Differentiation}

\textit{\textbf{Extremes within restricted domains}}
\end{center}

\textbf{Question}

Find the maximum and minimum values of

$$f(x,y)=x-x^2+y^2$$

On the rectangle $0 \le x \le 2$, $0 \le y \le 1$.


\textbf{Answer}

For critical points
\begin{eqnarray*}
0 & = & f_1(x,y)=1-2x\\
0 & = & f_2(x,y)=2y
\end{eqnarray*}
So the only CP is $(\frac{1}{2}, 0)$. This lies on the boundary of the
rectangle. This boundary has four segments:

On $x=0$
\begin{eqnarray*}
f(x,y) & = & f(0,y) = y^2\\
\textrm{for }0 \le y \le 1 & &
\end{eqnarray*}
This has min=0 and max=-1.

On $y=0$
\begin{eqnarray*}
f(x,y) & = & f(x,0) = x-x^2=g(x)\\
\textrm{for }0 \le x \le 2 & &
\end{eqnarray*}
Since $g'(x)=1-2x=0$ at $x=\frac{1}{2}$,
\begin{eqnarray*}
g(1/2) & = & 1/4\\
g(0) & = & 0\\
g(2) & = & -2
\end{eqnarray*}
This has min=-2 and max=1/4.

On $x=2$
\begin{eqnarray*}
f(x,y) & =& f(2,y) = -2+y^2\\
\textrm{for }0 \le y \le 1
\end{eqnarray*}
This has min=-2 and max=-1.

On $y=1$
\begin{eqnarray*}
f(x,y) & = & f(x,1) = x-x^2+1 = g(x)+1\\
\textrm{for }0 \le x \le 2
\end{eqnarray*}
This has min=-1 and max=5/4.

So on the rectangle, $f$ has 

minimum value=-2, maximum value=5/4.

\end{document}

