\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{enumerate}
\usepackage{ifthen}
\usepackage{ulem} % for strikethrough \sout{...} command
\usepackage{color}


% PGFPlots and Tikz
\usepackage{pgfplots}
%\pgfplotsset{compat=1.12}
\usepackage{tikz}

\setlength{\oddsidemargin}{-0.25in}
\setlength{\evensidemargin}{-0.25in}
\setlength{\topmargin}{-0.25in}
\setlength{\headheight}{0.0in}
\setlength{\headsep}{0.0in}
\setlength{\topskip}{0.0in}
\setlength{\textheight}{9.4in}
\setlength{\textwidth}{7in}

\newcommand{\bdot}{\, {\scriptstyle{\bullet}} \,}
\newcommand{\B}[1]{{\bf {#1}}}
\newcommand{\la}{\langle}
\newcommand{\ra}{\rangle}

\newcommand{\myspace}{\parbox[c][0.25in]{0.25in}{\hfill}}
\newcommand{\varspace}[2]{\mbox{\parbox[c][#1]{#2}{\hfill}}}
\newcommand{\force}{{\noindent $\mbox{\;}$}}

\begin{document}

%\pagestyle{empty}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\iffalse


\noindent
\parbox{2in}{\bf Math 2130}
\hfill {\Large \bf Test \#2} \hfill
\parbox{2in}{\bf \hfill June ${\bf 17}^\mathrm{\bf th}$, 2019}

\vspace{0.05in}

\noindent {\large\bf Name:} \underline{\Large\sc\color{red}\qquad Answer Key \qquad}
\hfill {\bf Be sure to show your work!}

\vspace{0.1in}

%\noindent
%If $F(x,y)=C$, then 
%$\displaystyle{ \frac{d y}{d x} = - \frac{F_x}{F_y}}$ \hfill \hfill
%If $F(x,y,z)=C$, then 
%$\displaystyle{ \frac{\partial z}{\partial x} = - \frac{F_x}{F_z}}$ and
%$\displaystyle{ \frac{\partial z}{\partial y} = - \frac{F_y}{F_z}}$

%\vspace{0.1in}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\iffalse
\noindent {\bf \large 1. (12 points)} Three level curve plots are shown below. I have labeled the levels so you know which curves are higher and which are lower.

\force \hfill
\begin{tikzpicture}[scale=0.6]
  \begin{axis}[
      axis x line=middle, 
      axis y line=middle, 
      axis equal,
      xlabel = {},  ylabel = {},
      xtick={0}, ytick={0},
      restrict y to domain = -1:1,
      restrict x to domain = -1:1,
      color=black!30
    ]
    \foreach \C in {-6,...,3}
       \addplot [domain = -1:1, samples = 300, color=black] ({x^2+\C/4}, {x});
    
    \node[fill=white] at (axis cs: -0.75,-0.85) {\color{red}\bf lower};
    \node[fill=white] at (axis cs: 0.75,0.85) {\color{red}\bf higher};
    
    \draw[red,fill=red,ultra thick] (axis cs:-0.25,0) circle [radius=3pt];
    \node[below left] at (axis cs:-0.25,0) {\color{red}\bf A};

    \draw[blue,ultra thick,->] (axis cs:-0.25,0)--(axis cs:0.3,0);
  \end{axis}
\end{tikzpicture}
\hfill
\begin{tikzpicture}[scale=0.6]
  \begin{axis}[
      axis x line=middle, 
      axis y line=middle, 
      axis equal,
      xlabel = {},  ylabel = {},
      xtick={0}, ytick={0},
      restrict y to domain = -1:1,
      restrict x to domain = -1:1,
      color=black!30
    ]
    \foreach \C in {1,...,10}
       \addplot [domain = 0:360, samples = 300, color=black] ({2*sqrt(\C)*0.2*cos(x)}, {3*sqrt(\C)*0.2*sin(x)});
    
    \node[fill=white] at (axis cs: 0.25,-0.45) {\color{red}\bf lower};
    \node[fill=white] at (axis cs: 0.75,-0.85) {\color{red}\bf higher};
    
    \draw[red,fill=red,ultra thick] (axis cs:-0.28,0.425) circle [radius=3pt];
    \node[below right] at (axis cs:-0.28,0.425) {\color{red}\bf B};

    \draw[blue,ultra thick,->] (axis cs:-0.28,0.425)--(axis cs:-0.7,0.75);
  \end{axis}
\end{tikzpicture}
\hfill
\begin{tikzpicture}[scale=0.6]
  \begin{axis}[
      axis x line=middle, 
      axis y line=middle, 
      axis equal,
      xlabel = {},  ylabel = {},
      xtick={0}, ytick={0},
      restrict y to domain = -1:1,
      restrict x to domain = -1:1,
      color=black!30
    ]
    \foreach \C in {-5,...,5}
       \addplot [domain = -1:1, samples = 300, color=black] ({x}, {-2*x^3+\C/2-0.15});
    
    \node[fill=white] at (axis cs: -0.5,-0.85) {\color{red}\bf lower};
    \node[fill=white] at (axis cs: 0.5,0.85) {\color{red}\bf higher};
    
    \draw[red,fill=red,ultra thick] (axis cs:0.25,-0.175) circle [radius=3pt];
    \node[below left] at (axis cs:0.25,-0.175) {\color{red}\bf C};

    \draw[blue,ultra thick,->] (axis cs:0.25,-0.175)--(axis cs:0.45,0.4);
  \end{axis}
\end{tikzpicture}
\hfill \force
  
\noindent  
\force \hfill 
\fbox{\quad $x-y^2$ \quad \Large\strut}  
\hfill \quad
\fbox{\quad $\dfrac{x^2}{2}+\dfrac{y^2}{3}$ \quad \Large\strut}
\hfill \quad
\fbox{\quad $2x^3+y$ \quad \Large\strut}
\hfill \force
  
\begin{enumerate}[(a)]
   \item The plots above correspond to 3 of the 5 functions listed here: $f(x,y)=x^2/2+y^2/3$, $f(x,y)=x^2+y^2$, $f(x,y)=2x^3+y$, $f(x,y)=y-x^2$, and $f(x,y)=x-y^2$. Write the correct formula below each plot.
   
   $x^2/2+y^2/3=C$ for positive constants $C$ would be ellipses: $x^2/(2C)+y^2/(3C)=1$ (the bigger $y$-term denominator, $3C$ vs. $2C$, means these ellipses should be taller than wide). Also, as $C$ increases they would have larger ``radii'' (bigger ellipses correspond to higher ground). This certainly matches the middle plot. $x^2+y^2=C$ yields circles of radius $\sqrt{C}$ (for positive $C$'s). This doesn't appear above. $2x^3+y=C$ yields $y=-2x^3+C$. These are the cubic $y=-2x^3$ (snaking downward) shifted vertically by $C$. This matches the third plot. $y-x^2=C$ yields $y=x^2+C$. These are parabolas opening upward (not pictured above). $x-y^2=C$ yields $x=y^2+C$. These are parabolas opening to the right (as $C$ increases, we shift further right). This matches our first plot.
   
   \item Sketch a gradient vector at the points A, B, and C. If the vector is $\B 0$ or does not exist, draw an ``X'' on the point.\\ {}[Don't worry about having the correct length. I'm just looking for the correct direction.] 
   
   Gradient vectors point ``up hill'' and are perpendicular to level curves. 
\end{enumerate}

\vspace{0.05in}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\fi

\noindent {\bf \large 2. (8 points)} Let $w=f(x,y,z)$, $x=g(u,v)$, $y=h(u,v)$, and $z=\ell(u,v)$.

State the chain rule for $\dfrac{\partial w}{\partial u}$.

\vspace{0.1in}

\fbox{$\dfrac{\partial w}{\partial u} = \dfrac{\partial w}{\partial x}\dfrac{\partial x}{\partial u}+\dfrac{\partial w}{\partial y}\dfrac{\partial y}{\partial u}+\dfrac{\partial w}{\partial z}\dfrac{\partial z}{\partial u}$}

\vspace{0.1in}

Alternate notations: 

$w_u=w_x\,x_u+w_y\,y_u+w_z\,z_u$ 

or 

$w_u=f_x\,g_u+f_y\,h_u+f_z\,\ell_u$.

\vspace{-1.5in}

\force \hfill
\begin{tikzpicture}[node distance=0.75in]

%\node[below left of=x] (xu) {$u$};
%\node[below right of=x] (xv) {$v$};
%\node[below left of=y] (yu) {$u$};
%\node[below right of=y] (yv) {$v$};
%\node[below left of=z] (zu) {$u$};
%\node[below right of=z] (zv) {$v$};
\node (xu) {$u$};
\node[right of=xu] (xv) {$v$};
\node[right of=xv] (yu) {$u$};
\node[right of=yu] (yv) {$v$};
\node[right of=yv] (zu) {$u$};
\node[right of=zu] (zv) {$v$};
\node[above right of=xu] (x) {$x$};
\node[above right of=yu] (y) {$y$};
\node[above right of=zu] (z) {$z$};
\node[above of=y] (w) {$w$};

\draw (w)--(x) node[midway,left] {$w_x$};
\draw (w)--(y) node[midway,left] {$w_y$};
\draw (w)--(z) node[midway,right] {$w_z$};

\draw (x)--(xu) node[midway,left] {$x_u$};
\draw (x)--(xv) node[midway,right] {$x_v$};
\draw (y)--(yu) node[midway,left] {$y_u$};
\draw (y)--(yv) node[midway,right] {$y_v$};
\draw (z)--(zu) node[midway,left] {$z_u$};
\draw (z)--(zv) node[midway,right] {$z_v$};

\end{tikzpicture}

\vspace{0.1in}

\noindent {\bf \large 3. (9 points)} Suppose we have a function $f(x,y)$ where $\nabla f(x,y)$ exists everywhere.

\begin{enumerate}[(a)]

\item It is possible for $f_{xy}(2,3)=4$ and $f_{yx}(2,3)=5$? If not, why not? If so, what does this tell us?

\fbox{Yes.} Clairaut's theorem says that mixed partials must be equal {\it if they are continuous}. Thus if $f_{xy}(2,3)=4 \not= 5=f_{yx}(2,3)$, then it must be that \fbox{$f_{xy}$ and $f_{yx}$ are discontinuous} at $(x,y)=(2,3)$.

\item Can I conclude $f(x,y)$ is differentiable? \qquad {\Large\bf YES \quad / \quad \fbox{NO}}

Since $\nabla f(x,y)$ exists, we have that $f$'s first partials exist. This is not enough to guarantee that $f$ is differentiable. If we knew that $f_x$ and $f_y$ were continuous, then we could conclude that $f$ is differentiable. But existence of first partials is not enough.

\item Can I conclude that $f(x,y)$ is continuous? \qquad {\Large\bf YES \quad / \quad \fbox{NO}}

Existence of partials is also not enough to guarantee that $f$ is continuous. If we knew that $f$ was differentiable, then that would be enough to guarantee $f$ is continuous.

\end{enumerate}

\newpage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\fi

\noindent {\bf\large 4. (10 points)} Limits and continuity.

\vspace{-0.1in}

\begin{enumerate}[(a)]
\item Where is the function $f(x,y)=\ln(x^2+y^2)$ continuous?
%\item Where is the function $f(x,y)=\sqrt{1-x^2-y^2}$ continuous?

The natural logarithm's domain is all positive reals (and it is continuous on its domain). Thus for $f(x,y)$ to be defined we need $x^2+y^2>0$. We know that $x^2+y^2 \geq 0$. Also, $x^2+y^2=0$ only if $x=y=0$. Thus the domain of $f(x,y)$ (which is where it is continuous)  is everywhere \fbox{$(x,y) \not= (0,0)$}.  Alternatively, we could write the domain as: $\{ (x,y) \in \mathbb{R}^2 \;|\; (x,y) \not= (0,0) \} = \mathbb{R}^2 - \{(0,0)\}$. 

\vspace{-0.1in}

\item Show that $\displaystyle \lim\limits_{(x,y) \to (0,0)} \dfrac{2xy}{x^2+y^2}$ does not exist. 
%\item Show that $\displaystyle \lim\limits_{(x,y) \to (0,0)} \dfrac{x^2-y^2}{x^2+y^2}$ does not exist. 

We typically shoot down (multivariate) limits by getting different limits when approaching along different curves. 

\vspace{-0.05in}

If we approach along the $y$-axis: $y=0$, the limit becomes $\lim\limits_{x \to 0} \dfrac{2x(0)}{x^2+0^2} = \lim\limits_{x\to 0} \dfrac{0}{x^2} = \lim\limits_{x\to 0} 0 =0$. 

Approaching along the $x$-axis would also yield $0$ (this doesn't help). Notice that $y=x$ ``unifies the denominator'' so let's approach along that line. We get $\lim\limits_{x\to 0} \dfrac{2x(x)}{x^2+x^2} = \lim\limits_{x\to 0} \dfrac{2x^2}{2x^2} = \lim\limits_{x\to 0} 1 =1$. 

Therefore, since approaching the origin along the $y$-axis yields $0$ while approaching the diagonal line $y=x$ yields $1$, this limit cannot exist (if it did all approaches would have to yield the same limit).

\end{enumerate}

\noindent {\bf \large 5. (14 points)} Let $F(x,y,z)=y^2z^3+e^{x^2z}$. \quad {\it Note:} All three parts use the same function and point.

\vspace{0.05in}

We need $\nabla F = \langle F_x,F_y,F_z \rangle = \langle 2xze^{x^2z}, 2yz^3, 3y^2z^2+x^2e^{x^2z} \rangle$ for future computations.

\vspace{-0.1in}

\begin{enumerate}[(a)]
\item Find an equation for the plane tangent to $y^2z^3+e^{x^2z}=-3$ at $(x,y,z)=(0,2,-1)$

The above equation is $F(x,y,z)=-3$ (i.e., we have a level surface of $F$). Thus $\nabla F(0,2,-1) =$\\ $\langle 0,2(2)(-1)^3,3(2^2)(-1)^2+0 \rangle = \langle 0,-4,12 \rangle$ is normal to the level surface $F(x,y,z)=-3$ at $(x,y,z)=(0,2,-1)$.

The plane normal to $\langle 0,-4,12\rangle$ and through the point $(0,2,-1)$ has equation \fbox{$0(x-0)-4(y-2)+12(z+1)=0$} (or $-4y+12z+20=0$ or $y-3z=5$).

\vspace{-0.05in}

\item Find the directional derivative $D_{\bf u}F(0,2,-1)$ where ${\bf u}$ points in the same direction as ${\bf v}=\langle 2,-2,1 \rangle$.

\vspace{-0.05in}

We need a unit vector $\B u = \dfrac{\B v}{|\B v|} = \dfrac{1}{\sqrt{2^2+(-2)^2+1^2}}\langle 2,-2,1 \rangle = \dfrac{1}{3}\langle 2,-2,1\rangle$. 

\vspace{-0.1in}

\force \hspace*{0.3in} $D_{\B u}F(0,2,-1) = \nabla F(0,2,-1) \bdot \B u = \langle 0,-4,12 \rangle \bdot \left( \dfrac{1}{3}\langle 2,-2,1 \rangle\right) = \dfrac{1}{3}\left(0(2)-4(-2)+12(1)\right) =$ \fbox{$\dfrac{20}{3}$}.

\vspace{-0.1in}

\item Find the direction vector $\B u$ which maximizes $D_{\bf u}F(0,2,-1)$. What is the maximum value?

Directional derivatives are maximized in the gradient direction and their maximal value is given by the magnitude of the gradient. [They are minimized the direction opposite that of the gradient and the minimal value is the magnitude of the gradient negated.] 

\vspace{-0.05in}

$\B u = \dfrac{\nabla F(0,2,-1)}{|\nabla  F(0,2,-1)|} = \dfrac{\langle 0,-4,12\rangle}{4\sqrt{0^2+(-1)^2+3^2}} = \dfrac{1}{4\sqrt{10}}\langle 0,-4,12\rangle =$ \fbox{$\dfrac{1}{\sqrt{10}}\langle 0,-1,3 \rangle$}. The directional derivative's maximal value at $(x,y,z)=(0,2,-1)$ is \fbox{$|\nabla F(0,2,-1)| = 4\sqrt{10}$}.

\end{enumerate}

\vspace{-0.1in}

\noindent {\bf\large 6. (8 points)} Let $e^{3x}\sin(y^2z)+y\ln(x^4+z^2)=99$. Assuming $z$ is a function of $x$ and $y$, find $\dfrac{\partial z}{\partial y}$.\\ 
The derivative of a function defined (implicitly) by $F(x,y,z) = e^{3x}\sin(y^2z)+y\ln(x^4+z^2)=99$ is\dots %\hfill {}[Don't worry about simplifying.]

\vspace{-0.1in}

$$\hspace*{1in} \dfrac{\partial z}{\partial y} = -\dfrac{F_y}{F_z} = \mbox{\fbox{$ -\dfrac{2yze^{3x}\cos(y^2z)+\ln(x^4+z^2)}{y^2e^{3x}\cos(y^2z)+\dfrac{2yz}{x^4+z^2}}$}}$$

\vspace{-0.2in}

\noindent {\bf \large 7. (13 points)} Let $f(x,y) = -x^4+4xy-2y^2-3$.
\begin{enumerate}[(a)]
   \item Compute the gradient and Hessian matrix for $f$.

\vspace{-0.25in}

$$\nabla f = \langle f_x,f_y \rangle = \mbox{\fbox{$\langle -4x^3+4y, 4x-4y \rangle$}} \qquad H_f = \begin{bmatrix} f_{xx} & f_{xy} \\ f_{yx} & f_{yy} \end{bmatrix} = \mbox{\fbox{$\begin{bmatrix} -12x^2 & 4 \\ 4 & -4 \end{bmatrix}$}}$$

\vspace{-0.25in}

   \item Find the quadratic approximation of $f$ at $(x,y)=(0,-1)$.

We need to plug in our point: $f(0,-1)=0+0-2(-1)^2-3=-5$, $\nabla f(0,-1) = \langle 0+4(-1), 0-4(-1) \rangle = \langle -4,4 \rangle$, and $H_f(0,-1) = \begin{bmatrix} 0 & 4 \\ 4 & -4 \end{bmatrix}$. \hfill
$\displaystyle Q(x,y) = \mbox{\fbox{$-5+\langle -4,4 \rangle \bdot \langle x-0,y+1 \rangle + \dfrac{1}{2} \begin{bmatrix} x & y+1 \end{bmatrix} \begin{bmatrix} 0 & 4 \\ 4 & -4 \end{bmatrix} \begin{bmatrix} x\\ y+1 \end{bmatrix}$}}$
 $$\text{or}\ \ Q(x,y)=-5-4x+4(y+1)+\dfrac{1}{2}(0)x^2+\dfrac{1}{2}(4)x(y+1)+\dfrac{1}{2}(4)x(y+1)+\dfrac{1}{2}(-4)(y+1)^2$$
 
   \item Find and classify all of the critical points of $f$. {}[Use the ``$2^{\mathrm{nd}}$-derivative'' test to determine if critical points are relative max's, min's or saddle points.]

{\it To speed you along:} There are exactly 3 critical points. Their $x$-coordinates are $x=0,\pm 1$. 

We need to solve $\nabla f = \langle -4x^3+4y, 4x-4y \rangle = \B 0$. Thus $-4x^3+4y=0$ and $4x-4y=0$ so $x^3-y=0$ and $x-y=0$. Thus $y=x$ so $x^3-x=0$. Factoring: $x(x^2-1)=x(x-1)(x+1)=0$. Thus $x=0,\pm 1$ (as we were told). Finally $y=x$ so our 3 critical points are just $(x,y)=(0,0)$, $(1,1)$, and $(-1,-1)$. 

To classify: $H_f(0,0) = \begin{bmatrix} 0 & 4 \\ 4 & -4 \end{bmatrix}$ thus $\det H_f(0,0) = 0(-4)-4(4)=-16<0$. Therefore, \fbox{$(0,0)$ is a saddle point.} Next, $H(\pm 1,\pm 1) = \begin{bmatrix} -12(\pm 1)^2 & 4 \\ 4 & -4 \end{bmatrix} = \begin{bmatrix} -12 &  4 \\ 4 & -4 \end{bmatrix}$ so $\det H_f(\pm 1,\pm 1) = -12(-4)-4(4) = 32>0$ and $f_{xx}(\pm 1,\pm 1) = -12<0$. Therefore, \fbox{$(1,1)$ and $(-1,-1)$ are relative maximums.}
   
\end{enumerate}

\vspace{-0.05in}

\noindent {\bf \large 8. (14 points)} Suppose $f(x,y)$ is a ``nice'' function (with continuous partials of all orders).

\vspace{-0.05in}

\begin{enumerate}[(a)]
\item $Q(x,y) = 1+2(x-1)+3(x-1)(y+2)+4(y+2)^2$ is the quadratic approx. at $(x,y)=(1,-2)$. 

We can either match $Q$'s coefficients to what they should be or we can use the fact that $Q$ and $f$ have matching first and second partial values at our base point $(1,-2)$. Thus differentiating $Q$ and plugging in $(1,-2)$ can give us our answers. Reading off coefficients we have that $f(1,-2)=1$ then\dots

\vspace{-0.15in}

$$\mbox{\fbox{$\nabla f(1,-2) = \la 2,0 \ra$ \qquad $H_f(1,-2) = \begin{bmatrix} 0 & 3 \\ 3 & 8 \end{bmatrix}$}} $$

\vspace{-0.05in}

Notice that there is no $(y+2)$ term so the second entry of $\nabla f(1,-2)$ is $0$. Similarly the $(x-1)^2$ term is missing so $f_{xx}(1,-2)=0$. The coefficient next to $(x-1)(y+2)$ is $3$. This must account for both $\dfrac{f_{xy}(1,-2)}{2}$ and $\dfrac{f_{yx}(1,-2)}{2}$ (which should be equal since we have continuous partials). So $3 = \dfrac{f_{xy}(1,-2)}{2} + \dfrac{f_{yx}(1,-2)}{2} = {f_{xy}(1,-2)}$. Finally, the coefficient of $(y+2)^2$ is $4$ which should match $f_{yy}(1,-2)/2$. Thus $f_{yy}(1,-2)=8$.

%\vspace{0.1in}

Is $(x,y)=(1,-2)$ a critical point of $f(x,y)$?  {\large\bf \qquad YES \quad / \quad \fbox{NO}}

If not, why not? If so, what kind (relative min, relative max, saddle point or not enough information)?

To be a critical point the function needs to be non-differentiable or the gradient needs to be zero. However, since $f$ has continuous partials, it must be differentiable and we found that \fbox{$\nabla f(1,-2) \not= \B 0$}. Therefore, $(1,-2)$ is not a critical point.

To get the linearization at $(1,-2)$ we just throw away the second order terms in $Q(x,y)$.

The linearization of $f(x,y)$ at $(x,y)=(1,-2)$ is $L(x,y)=$ \underline{\quad $1+2(x-1)$ \quad}
%\force \hfill {}[If there is not enough information answer ``N/A''.]

\item $Q(x,y) = 12-5(x-2)^2+(x-2)y-3y^2$ is the quadratic approx. at $(x,y)=(2,0)$. 

\vspace{-0.05in}

$$\mbox{\fbox{$\nabla f(2,0) = \la 0,0 \ra$ \qquad $H_f(2,0) = \begin{bmatrix} -10 & 1 \\ 1 & -6 \end{bmatrix}$}}$$

\vspace{-0.05in}

Is $(x,y)=(2,0)$ a critical point of $f(x,y)$?  {\large\bf \qquad \fbox{YES} \quad / \quad NO}

If not, why not? If so, what kind (relative min, relative max, saddle point or not enough information)?

This is a critical point since $\nabla f(2,0) = \B 0$. Notice that $\det H_f(2,0) = -10(-6)-1(1) = 59>0$ and $f_{xx}(2,0)=-10<0$ so this is a \fbox{relative maximum}.

\end{enumerate}

\noindent {\bf \large 9. (12 points)} Use the method of Lagrange multipliers to find the minimum and maximum values of 

\force \hfill $f(x,y)= 2x-4y$ constrained to $x^2+y^2=5$. 

Given $f(x,y)=2x-4y$ and $g(x,y)=x^2+y^2$, $\nabla f = \langle 2,-4 \rangle = \lambda \nabla g = \lambda \la 2x,2y \ra$. Thus we get the equations: $2=2x\lambda$, $-4=2y\lambda$, and $x^2+y^2=5$. 

Let's symmetrize the first two equations (multiply the first equation by $y$ and the second by $x$): $2y=2xy\lambda=-4x$. Therefore, $y=-2x$. Plugging this into the constraint yields $x^2+(-2x)^2=5$ so that $5x^2=5$. Thus $x=\pm 1$. Now $y=-2x$ so $y=\mp 2$. Our two critical points are $(x,y)=(-1,2)$ and $(1,-2)$.  Plugging these into our objective function yields $f(-1,2)=2(-1)-4(2)=-10$ and $f(1,-2)=2(1)-4(-2)=10$. 

Therefore, $f$ subject to the constraint $x^2+y^2=5$ attains a \fbox{maximum value of $10$} at $(x,y)=(1,-2)$ and a \fbox{minimum value of $-10$} at $(x,y)=(-1,2)$. 


\end{document}