\documentclass[notes=show,10pt]{beamer}
\usepackage{mathpazo}			%% Beamer stuff
\usepackage{amsmath}			%% AMS math packages
\usepackage{amsfonts}			%%	-	special fonts
\usepackage{amssymb}			%%	-	special symbols
\usepackage{graphicx}			%% graphics
\usepackage{tcolorbox}			%% color boxes

\usepackage{hyperref}			%% for web links
\hypersetup{
%    bookmarks=true,         		% show bookmarks bar?
    unicode=false,          		% non-Latin characters in Acrobat’s bookmarks
    pdftoolbar=true,        		% show Acrobat’s toolbar?
    pdfmenubar=true,        	% show Acrobat’s menu?
    pdffitwindow=false,     		% window fit to page when opened
    pdfstartview={FitH},    		% fits the width of the page to the window
    pdfnewwindow=true,      	% links in new PDF window
    colorlinks=true,       			% false: boxed links; true: colored links
    linkcolor=blue,          		% color of internal links (change box color with linkbordercolor)
    citecolor=PineGreen,    		% color of links to bibliography
    filecolor=magenta,      		% color of file links
    urlcolor=cyan           		% color of external links
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		TiKZ Ploting Stuff
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{tikz}				%% TikZ -graphics

\usetikzlibrary{arrows, positioning, calc, intersections}
\usetikzlibrary{decorations.pathreplacing, decorations.markings}

\usepackage{pgfplots}			%% fancy plotting

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	For 3d plotting, using the tikz-3dplot package so
%	that (x,y,z) coordinates are specified in normal order
%	and one can change the perspective for 3-d plots
%
%	To invoke, use
%
%	\begin{tikzpicture}[tdplot_main_coords,{other options}]
%		...
%	\end{tikzpicture}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{tikz-3dplot}		%% Enhanced 3d plotting

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		Package forest to draw tree diagrams for chain rule
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{forest}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	adjustbox package to force minipage alignment
%
%	Two-column structure is
%
%	\adjustbox{valign=t}
%		{
%			\begin{minipage}{0.45\textwidth}
%			...
%			\end{minipage}
%		}
%	\adjustbox{valign=t}
%		{
%		
%			\begin{minipage}{0.45\textwidth}
%			...
%			\end{minipage}
%		}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{adjustbox}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		Set Beamer theme
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usetheme{Dresden}
\usecolortheme{dolphin}

%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		Hack to remove subsection bar from our
%		friends at Tex.StackExchange.Com
%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\beamer@theme@subsectionfalse

\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%
%		
%		Hack to make the nice little circles appear
%		from Tex.stackexchange.com
%
%		Reference: 
%
%		https://tex.stackexchange.com/questions/2072/beamer-navigation-circles-without-subsections
%
%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{remreset}
\makeatletter
\@removefromreset{subsection}{section}
\makeatother
\setcounter{subsection}{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		Get rid of triangles, put in circles for 
%		itemize items
%
%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{items}[circle]

%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		Clean up fonts
%
%%%%%%%%%%%%%%%%%%%%%%%%%%

\usefonttheme{professionalfonts}
\usefonttheme{serif}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		tikz plotting options
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\pgfplotsset{my style/.append style={axis x line=middle, axis y line=
           middle, xlabel={}, ylabel={}, axis equal }}
           
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		Math Operators
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\DeclareMathOperator{\comp}{comp}
\DeclareMathOperator{\proj}{proj}
\DeclareMathOperator{\Hess}{Hess}

\DeclareMathOperator{\curl}{curl}
\DeclareMathOperator{\diver}{div}
\DeclareMathOperator{\grad}{grad}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Document begins here...
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
           
\begin{document}

\input{213-Lecture-Macros}		%% 	macros, settings, et.c


\title{Math 213 - Maximum and Minimum Values, I}			%%	title page
\author{Peter A. Perry}
\institute{University of Kentucky}
\date{October 4, 2019}
\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%	
%	Due Date Reminders
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
\frametitle{Reminders}

\begin{itemize}
\item	Homework B4 on 14.5 is due tonight
\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Unit Outline
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
\frametitle{Unit II: Functions of Several Variables}
\begin{itemize}

\item[{13.3-4}] 	Lecture 11: Velocity and Acceleration

\medskip

\item[{14.1}] Lecture 12: Functions of Several Variables

\item[{14.3}] Lecture 13: Partial Derivatives
\item[{14.4}] Lecture 14: Linear Approximation
\item[{14.5}] Lecture 15: Chain Rule, Implicit Differentiation

\item[{14.6}] Lecture 16: Directional Derivatives and the Gradient


\medskip

\begingroup
\color{red}
\item[{14.7}] Lecture 17: Maximum and Minimum Values, I
\endgroup
\item[{14.7}] Lecture 18: Maximum and Minimum Values, II
\item[{14.8}] Lecture 19: Lagrange Multipliers

\medskip

\item[{15.1}]	Double Integrals
\item[{15.2}]	Double Integrals over General Regions
\item[{}]			Exam II Review
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%	Learning Goals
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{frame}
\frametitle{Learning Goals}
\begin{itemize}
\item	Know how to find a critical point of a function of two variables
\item	Know how to use the second derivative test to determine whether
		a given critical point is a local maximum, a local minimum, or a 
		saddle point
\item	Know how to use the second derivative test to solve simple maximization and minimization problems
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%		New material begins here...
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Calculus I versus Calculus III}

\begin{frame}
\frametitle{Review of Calculus I}
\begin{minipage}{0.25\textwidth}

\begin{tikzpicture}[scale=0.5]
\draw[thick,->,>=stealth]	(-2.5,0)	--	(2.5,0);
\draw[thick,->,>=stealth]	(0,-0.5)	--	(0,2.5);
\draw[thick,red]	plot[domain=-2:2]	({\x},{0.5*\x*\x});
\end{tikzpicture}

\bigskip

\begin{tikzpicture}[scale=0.5]
\draw[thick,->,>=stealth]	(-2.5,0)	--	(2.5,0);
\draw[thick,->,>=stealth]	(0,-2.5)	--	(0,1);
\draw[thick,red]	plot[domain=-2:2]	({\x},{-0.5*\x*\x});
\end{tikzpicture}

\bigskip

\begin{tikzpicture}[scale=0.5]
\draw[thick,->,>=stealth]	(-2.5,0)	--	(2.5,0);
\draw[thick,->,>=stealth]	(0,-2.5)	--	(0,2.5);
\draw[thick,red]	plot[domain=-2:2]	({\x},{0.25*\x*\x*\x});
\end{tikzpicture}

\end{minipage}
\qquad
\begin{minipage}{0.65\textwidth}
\footnotesize
If $y=f(x)$ then local maxima and minima occur at \emph{critical points} $a$ where
$f'(a)=0$ or $f'(a)$ does not exist. There are two main tests:

\bigskip
\emph{First Derivative Test}: 
\begin{itemize}
\item		If $f'(a)=0$ and $f'(x)$ changes from $-$ to $+$ then $f(a)$ is a local minimum value
\item		If $f'(a)=0$ and $f'(x)$ changes from $+$ to $-$ at $x=a$, then $f(a)$ is a local maximum value
\item		If $f'(a)=0$ but $f'(x)$ does not change sign at $x=a$, then $f(a)$ is neither a local maximum value nor a local minimum value
\end{itemize}
\end{minipage}
\end{frame}

\begin{frame}
\frametitle{Review of Calculus I}

\begin{minipage}{0.25\textwidth}

\begin{tikzpicture}[scale=0.5]
\draw[thick,->,>=stealth]	(-2.5,0)	--	(2.5,0);
\draw[thick,->,>=stealth]	(0,-0.5)	--	(0,2.5);
\draw[thick,red]	plot[domain=-2:2]	({\x},{0.5*\x*\x});
\end{tikzpicture}

\bigskip

\begin{tikzpicture}[scale=0.5]
\draw[thick,->,>=stealth]	(-2.5,0)	--	(2.5,0);
\draw[thick,->,>=stealth]	(0,-2.5)	--	(0,1);
\draw[thick,red]	plot[domain=-2:2]	({\x},{-0.5*\x*\x});
\end{tikzpicture}

\bigskip

\begin{tikzpicture}[scale=0.5]
\draw[thick,->,>=stealth]	(-2.5,0)	--	(2.5,0);
\draw[thick,->,>=stealth]	(0,-2.5)	--	(0,2.5);
\draw[thick,red]	plot[domain=-2:2]	({\x},{0.25*\x*\x*\x});
\end{tikzpicture}

\end{minipage}
\qquad
\begin{minipage}{0.65\textwidth}
\footnotesize
If $y=f(x)$ then local maxima and minima occur at \emph{critical points} $a$ where
$f'(a)=0$ or $f'(a)$ does not exist. There are two main tests:

\bigskip
\emph{Second Derivative Test}: 
\begin{itemize}
\item		If $f'(a)=0$ and $f''(a) > 0$, then $f(a)$ is a local minimum value
\item		If $f'(a)=0$ and $f''(a) < 0$, then $f(a)$ is a local maximum value
\item		If $f'(a)=0$ but $f''(a) = 0$, the test is indeterminate
\end{itemize}
\end{minipage}
\end{frame}

\begin{frame}
\frametitle{Preview of Calculus III}
\begin{minipage}{0.25\textwidth}




\begin{tikzpicture}[scale=0.4]
\begin{axis}[
	title={$x^2+y^2$ },
	xlabel=$x$,
	ylabel=$y$,
	small,
]
\addplot3[
	surf,
	domain=-2:2,
	domain y = -2:2,
]
	{x^2+y^2};
\end{axis}
\end{tikzpicture}

\bigskip

\begin{tikzpicture}[scale=0.4]
\begin{axis}[
	title={$-(x^2+y^2)$ },
	xlabel=$x$,
	ylabel=$y$,
	small,
]
\addplot3[
	surf,
	domain=-2:2,
	domain y = -2:2,
]
	{-(x^2+y^2)};
\end{axis}
\end{tikzpicture}

\bigskip

\begin{tikzpicture}[scale=0.4]
\begin{axis}[
	title={$x^2-y^2$ },
	xlabel=$x$,
	ylabel=$y$,
	small,
]
\addplot3[
	surf,
	domain=-2:2,
	domain y = -2:2,
]
	{x^2-y^2};
\end{axis}
\end{tikzpicture}

\end{minipage}
\qquad
\begin{minipage}{0.65\textwidth}
\footnotesize
There is \emph{no} ``first derivative test'' and instead the nature of the critical point depends on the \emph{Hessian matrix}
$$ \Hess(f) (a,b) = 	\begin{pmatrix}
							f_{xx}(a,b)	&	f_{xy}(a,b)	\\
							f_{yx}(a,b)	&	f_{yy}(a,b)
						\end{pmatrix},
$$	
and its determinant
$$
D =	f_{xx}(a,b)f_{yy}(a,b)  - f_{xy}(a,b)^2
$$
In the graphs at left:
\begin{itemize}

\item	
		$\Hess(f)(0,0)=	
			\begin{pmatrix}
				2	&	0	\\	
				0	&	2
			\end{pmatrix}
			\quad D = +4
		$
\item
		$ \Hess(f)(0,0)=
			\begin{pmatrix}
					-2	&	0	\\
					0	&	-2
			\end{pmatrix}, 
			\quad D = +4
		$
\item	
		$\Hess(f)(0,0)=
			\begin{pmatrix}
				2	&	0	\\
				0	&	-2
			\end{pmatrix}
		\quad D = -4
		$
\end{itemize}

\end{minipage}
\end{frame}

\section{Second Derivative Test}

\begin{frame}
\frametitle{Local and Absolute Extrema}
\footnotesize
A function $f(x,y)$ has a local maximum at $(a,b)$ if $f(x,y) \leq f(a,b)$ for all $(x,y)$ near $(a,b)$. 

\medskip

A function $f(x,y)$ has a local minimum at $(a,b)$ if $f(x,y) \geq f(a,b)$ for all $(x,y)$ near $(a,b)$. 

\medskip

What does it mean for a function to have an absolute maximum value (resp.\ absolute minimum value) at $(a,b)$?

\end{frame}

\begin{frame}
\frametitle{Hunting License for Local Extrema}
\footnotesize
\fcolorbox{cyan}{white}
{
\begin{minipage}{0.85\textwidth}
{\color{cyan}\textbf{Theorem}} If $f$ has a local maximum or a local minimum at $(a,b)$, and the first-order partial derivatives of $f$ exist there, then 
$$f_x(a,b)  = f_y(a,b) = 0.$$
\end{minipage}
}

\vfill


A value of $(a,b)$ where $f_x(a,b)$ and $f_y(a,b)$ are either zero or do not exist is called a \emph{critical point} for the function $f$.

\vfill
\end{frame}

\begin{frame}
\frametitle{Critical Points}
\footnotesize
To find the critical points of a function $f(x,y)$, you need to solve for the values $(a,b)$ that make \emph{both} $f_x(a,b)$ and $f_y(a,b)$ equal to zero.

\medskip
\textbf{Examples}

\begin{enumerate}
\item		Find all the critical points of the function $f(x,y) = x^3-3x+3xy^2$
\item		Find the critical points of $f(x,y) = x^2+y^4+2xy$
\item		Find the critical points of $f(x,y) = e^x \cos y$
\end{enumerate}

\end{frame}


\begin{frame}
\frametitle{Second Derivative Test}
\footnotesize
\fcolorbox{cyan}{white}
{
\begin{minipage}{0.85\textwidth}
{\color{cyan} \textbf{Second Derivatives Test}} Suppose  $f$ has second partial derivatives continuous on a disc at $(a,b)$, and $f_x(a,b) = f_y(a,b) = 0$. Let
$$ D = 
\begin{vmatrix}
f_{xx}(a,b)	&	f_{xy}(a,b)	\\[5pt]
f_{xy}(a,b)	&	f_{yy}(a,b)
\end{vmatrix}
$$
\begin{enumerate}

\item[(a)]	If $D>0$ and $f_{xx}(a,b) > 0$, then $f(a,b)$ is a local minimum
\item[(b)]	If $D>0$ and $f_{xx}(a,b) < 0$, then $f(a,b)$ is a local maximum
\item[(c)]	If $D<0$, then $f(a,b)$ is a saddle point (neither a maximum nor a minimum)

\end{enumerate}
\end{minipage}
}
\end{frame}

\begin{frame}
\footnotesize
\begin{enumerate}
\item[(a)]	If $D>0$ and $f_{xx}(a,b) > 0$, then $f(a,b)$ is a local minimum
\item[(b)]	If $D>0$ and $f_{xx}(a,b) < 0$, then $f(a,b)$ is a local maximum
\item[(c)]	If $D<0$, then $f(a,b)$ is a saddle point (neither a maximum nor a minimum)
\end{enumerate}

\bigskip

Classify the critical points of the following functions:

\begin{enumerate}
\item		$f(x,y) = x^3-3x+3xy^2$
\item		$f(x,y) = x^2+y^4+2xy$
\item		$f(x,y) =\sin(x)\sin(y)$
\end{enumerate}

\end{frame}

\begin{frame}
\footnotesize
\begin{center}
\begin{minipage}{0.25\textwidth}
\begin{tikzpicture}[scale=0.4]
\begin{axis}[
	title={$x^3-3x+3xy^2$ },
	xlabel=$x$,
	ylabel=$y$,
	small,
]
\addplot3[
	surf,
	domain=-3:3,
	domain y = -3:3,
]
	{x^3-3*x+3*x*y^2};
\end{axis}
\end{tikzpicture}
\end{minipage}
\qquad
\begin{minipage}{0.25\textwidth}
\begin{tikzpicture}[scale=0.4]
\begin{axis}[
	title={$x^2+4y^2+2xy$ },
	xlabel=$x$,
	ylabel=$y$,
	small,
]
\addplot3[
	surf,
	domain=-3:3,
	domain y = -3:3,
]
	{x^2+4*y^2+2*x*y};
\end{axis}
\end{tikzpicture}
\end{minipage}
\qquad
\begin{minipage}{0.25\textwidth}
\begin{tikzpicture}[scale=0.4]
\begin{axis}[
	title={$\sin x \sin y$ },
	xlabel=$x$,
	ylabel=$y$,
	small,
]
\addplot3[
	surf,
	domain=-5:5,
	domain y = -5:5,
	samples=50
]
	{sin(57.23*x)*sin(57.23*y)};
\end{axis}
\end{tikzpicture}
\end{minipage}


\end{center}
\end{frame}

\begin{frame}
\frametitle{Maximum and Minimum Problems}
\footnotesize
\begin{enumerate}
\item		Find the shortest distance from the point $(2,0,-3)$ to the plane
$x+y+z=1$.
\item		Find the point on the plane $x-2y^3z=6$ that is closest to the point $(0,1,1)$.
\end{enumerate}
\end{frame}

\section{Absolute Extrema}

\begin{frame}
\frametitle{Review of Calculus I}
\footnotesize
\fcolorbox{cyan}{white}
{
\begin{minipage}{0.85\textwidth}
{\color{cyan} \textbf{The Closed Interval Method}}
To find the \emph{absolute} maximum and minimum values of a continuous function on a closed interval $[a,b]$:
\begin{enumerate}
\item	Find the values of $f$ at the critical numbers of $f$ in $[a,b]$
\item	Find the values of $f$ at the endpoints of the interval
\item	The largest of the values from steps 1 and 2 is the absolute maximum of $f$ on $[a,b]$; the smallest of these values is the absolute minimum of $f$ on $[a,b]$.
\end{enumerate}
\end{minipage}
}

\bigskip
For functions of two variables:

\smallskip
\begin{enumerate}
\item	The ``closed interval'' on the line is replaced by a ``closed set'' in the plane
\item	The boundary of a closed set is a \emph{curve} rather than just two points
\end{enumerate}
Otherwise, the idea is much the same!
\end{frame}

\begin{frame}
\frametitle{Bounded Sets, Closed Sets, Boundaries}
\footnotesize
\begin{minipage}{0.3\textwidth}
\begin{tikzpicture}[scale=0.5]
\fill[yellow]	(-1.5,-1.5)	rectangle (1.5,1.5);
\drawxy{3}
\only<1>
{
\draw[dashed,red,thick]	(0,0)	circle(3cm);
}
\only<2>
{
\draw[cyan,fill=cyan]	(1.5,0.5)	circle(0.05cm);
}
\only<3>
{
\draw[cyan]	(-1.5,-1.5) rectangle (1.5,1.5);
}
\end{tikzpicture}


\end{minipage}
\qquad
\begin{minipage}{0.6\textwidth}
A \emph{bounded set} $D$ in $\R^2$ is a set that can be enclosed inside a large enough circle

\medskip

\uncover<2->
{
A \emph{boundary point} is a point $(a,b)$ that has points in $D$ and has points that don't belong to $D$ arbitrarily close to it
}

\medskip

\uncover<3->
{
The \emph{boundary} of a set $D$ is the set consisting of all the boundary points
}

\medskip

\uncover<4->
{
A \emph{closed} set $D$ is one that contains all of its boundary points. 
}
\end{minipage}


\end{frame}

\begin{frame}
\frametitle{Bounded Sets, Closed Sets, Boundaries}
\footnotesize
Classify each of the following sets as bounded or not bounded, and closed or not closed

\bigskip
\begin{enumerate}
\item	$D = \{ (x,y): x^2 + y^2 < 1 \}$
\item	$D = \{ (x,y,): x^2 + y^2 \leq 1 \}$
\item	$D = \{ (x,y): x^2 + y^2 \geq 1 \}$
\item $D = \{ (x,y): x^2 + y^2 > 1\}$ 
\end{enumerate}
\end{frame}

\begin{frame}
\frametitle{The Extreme Value Theorem}
\fcolorbox{cyan}{white}
{
\begin{minipage}{0.85\textwidth}
{\color{cyan} \textbf{Extreme Value Theorem}} If $f$ is continuous on a closed, bounded set $D$ in $\R^2$, then $f$ attains an absolute maximum value $f(x_1,y_1)$ and an absolute minimum value $f(x_2,y_2)$ at some points $(x_1,y_1)$ and $(x_2,y_2)$ in $D$.
\end{minipage}
}

\vfill

\emph{Practical fact:} These extreme values occur either in the interior of $D$, where the second derivative test works, or on the boundary of $D$, where the search for maxima and minima  can be reduced to a Calculus I problem.
\end{frame}


\begin{frame}
\frametitle{Summary}
\begin{itemize}
\item	We reviewed how to find local maxima and minima of functions of one variable
\item	We learned how to find local maxima, minima, and saddle points for functions of two variables using the gradient $\nabla f$ (to find critical points) and the determinant of the Hessian matrix (to classify the critical points as maxima, minima, or saddle points)
\item	We learned about the Extreme Value Theorem for a continuous function of two variables on a closed, bounded set
\end{itemize}
\end{frame}




\end{document}