\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 - Vector Fields}			%%	title page
\author{Peter A. Perry}
\institute{University of Kentucky}
\date{November 6, 2019}
\maketitle

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

\begin{frame}
\frametitle{Reminders}

\begin{itemize}
\item	Homework C5 on 15.9 (change of variables) is due tonight
\item	Quiz \#8 on 15.7--15.8 (triple integrals in spherical and cylindrical coordinates) takes place tomorrow
\item	Homework C6 on 16.1 (vector fields) is due Friday

\end{itemize}

\end{frame}

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

\begin{frame}
\frametitle{Unit III: Multiple Integrals, Vector Fields}
\begin{itemize}

\item[{}]			Double Integrals in Polar Coordinates
\item[{}]			Triple Integrals (Part I)
\item[{}]			Triple Integrals (Part II)
\item[{}]			Triple Integrals in Cylindrical Coordinates
\item[{}]			Triple Integrals in Spherical Coordinates



\item[{}]			Change of Variables, Part I

\item[{}]			Change of Variables, Part II

\medskip

\begingroup
\color{red}
\item[{}]			Vector Fields
\endgroup
\item[{}]			Line Integrals (Scalar functions)
\item[{}]			Line Integrals (Vector functions)


\medskip

\item[{}]			Exam III Review
\end{itemize}
\end{frame}

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

\section{Learning Goals}

\begin{frame}
\frametitle{Goals of the Day}
\begin{itemize}
\item	Understand and Visualize Vector Fields
\item	Know what the \emph{gradient vector field} of a function is
\end{itemize}
\end{frame}




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

\section{Vector Fields in the $xy$-Plane ($\R^2$)}

\begin{frame}
\frametitle{Vector Fields in the Plane}
\footnotesize
A \textbf{vector} field on $\R^2$ is a function that associates to each $(x,y)$ a \emph{vector} 
$$\bfF(x,y) = P(x,y) \ii + Q(x,y) \jj$$
We can visualize a vector field by a \emph{field plot}

\bigskip
\begin{tikzpicture}[scale=0.43]
\begin{axis}
	[
		title={$\bfF(x,y) = x \ii + y \jj$},
		view={0}{90},
		domain=-2:2,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={x},v={y},scale arrows=0.2},-stealth,samples=15]
		{0};
\end{axis}		 
\end{tikzpicture}
\quad
\begin{tikzpicture}[scale=0.43]
\begin{axis}
	[
		title={$\bfF(x,y) = y \ii  - x \jj$},
		view={0}{90},
		domain=-2:2,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={y},v={-x},scale arrows=0.2},-stealth,samples=15]
		{0};
\end{axis}		 
\end{tikzpicture}
\quad
\begin{tikzpicture}[scale=0.43]
\begin{axis}
	[
		title={$\bfF(x,y) = x \ii $},
		view={0}{90},
		domain=-2:2,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={x},v={0},scale arrows=0.2},-stealth,samples=15]
		{0};
\end{axis}		 
\end{tikzpicture}

\end{frame}

\begin{frame}
\frametitle{Breaking It Down}
\footnotesize
Where do these plots come from? Consider
$$ \bfF(x,y) = y\ii - x \jj$$

\vfill

\begin{minipage}{0.45\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}
	[
		title={$\bfF(x,y) = y \ii  - x \jj$},
		view={0}{90},
		domain=-2:2,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={y},v={-x},scale arrows=0.3},-stealth,samples=5]
		{0};
\end{axis}		 
\end{tikzpicture}
\end{minipage}
\quad
\begin{minipage}{0.45\textwidth}
\scriptsize
{\renewcommand{\arraystretch}{1.5}
\begin{tabular}{|c|c||c|c|}
\hline
$\langle x,y \rangle$	&	$\bfF(x,y)$		&	$\langle x,y \rangle$	&	$\bfF(x,y)$ \\
\hline
$\langle 1,0 \rangle$	&	$\langle 0,-1 \rangle$	&
$\langle 0,1 \rangle$	&	$\langle 1, 0 \rangle$	\\
\hline
$\langle	1,1 \rangle$	&	$\langle 1, -1 \rangle$	&
$\langle -1,-1 \rangle$		&	$\langle -1, 1 \rangle$ \\
\hline
$\langle 1, -1 \rangle$		&	$\langle -1, -1 \rangle$	&
$\langle -1,1  \rangle$		&	$\langle 1, 1 \rangle$	\\
\hline
$\langle 2,0 	\rangle$		&	$\langle 0, -2 \rangle$		&
$\langle 0,2	\rangle$		&	$\langle	2,0	\rangle$	\\
\hline
$\langle 2,2 \rangle$		&	$\langle 2, -2 \rangle$	&
$\langle -2,-2 \rangle$		&	$\langle -2, 2 \rangle$	\\
\hline
$\langle 2,-2 \rangle$		&	$\langle -2, -2 \rangle$	&
$\langle -2,2 \rangle$		&	$\langle 2, 2 \rangle$\\
\hline
\end{tabular}
}
\end{minipage}

\vfill
Notice that $\bfF(x,y)$ is always perpendicular to the vector $\bfr = x \ii + y \jj$
\end{frame}

\begin{frame}
\frametitle{Mix and Match}
\scriptsize
Can you match the vector field with its field plot?

\medskip

\begin{tabular}{rllrl}
{\color{blue} \textbf{A}}	&	$\bfF(x,y) 	= 	\langle x, -y \rangle$	&&
{\color{blue} \textbf{B}}	&	$\bfF(x,y)	=	\langle y,x-y \rangle$	\\
{\color{blue} \textbf{C}}	&	$\bfF(x,y)	=	\langle y,y+2 \rangle$	&&							
{\color{blue} \textbf{D}}	&	$\bfF(x,y)	=	\langle \cos(x+y), x \rangle$
\end{tabular}

\bigskip

\begin{center}
\begin{tikzpicture}[scale=0.45]
\begin{axis}
	[
		title={Door Number One},
		view={0}{90},
		domain=-3:3,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={x},v={-y},scale arrows=0.2},-stealth,samples=15]
		{0};
\end{axis}		 
\end{tikzpicture}
\quad
\begin{tikzpicture}[scale=0.45]
\begin{axis}
	[
		title={Door Number Two},
		view={0}{90},
		domain=-3:3,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={y},v={y+2},scale arrows=0.15},-stealth,samples=15]
		{0};
\end{axis}		 
\end{tikzpicture}

\vfill

\begin{tikzpicture}[scale=0.45]
\begin{axis}
	[
		title={Door Number Three},
		view={0}{90},
		domain=-3:3,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={cos(x+y)},v={x},scale arrows=0.2},-stealth,samples=15]
		{0};
\end{axis}		 
\end{tikzpicture}
\quad
\begin{tikzpicture}[scale=0.45]
\begin{axis}
	[
		title={Door Number Four},
		view={0}{90},
		domain=-3:3,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={y},v={x-y},scale arrows=0.15},-stealth,samples=15]
		{0};
\end{axis}		 
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}
\frametitle{Flow Lines}
\footnotesize
An important example of a vector field is the \emph{velocity field} of a fluid. 
The vector $\bfv(x,y)$ is the velocity vector for the fluid at the point $\langle x,y \rangle$ in the plane. Given the velocity field, you can find the \emph{flow lines} of the fluid -- the paths that fluid particles take.

\vfill

\begin{minipage}{0.45\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}
	[
		title={Velocity Field $\bfv(x,y) = y \ii  - x \jj$},
		view={0}{90},
		domain=-2:2,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={y},v={-x},scale arrows=0.3},-stealth,samples=5]
		{0};
\end{axis}		
\end{tikzpicture} 
\end{minipage}
\quad
\begin{minipage}{0.45\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}
	[
		title={Flow lines of Velocity Field}
	]
\foreach \r in {0.5,1,1.5,2}
{
		\addplot[no marks,red,domain=0:360,samples=41] 
			({\r*cos(x)}, {\r*sin(x)});
}
\end{axis}
\end{tikzpicture}
\end{minipage}
\end{frame}

\begin{frame}
\frametitle{Flow Lines}
\footnotesize
An important example of a vector field is the \emph{velocity field} of a fluid. 
The vector $\bfv(x,y)$ is the velocity vector for the fluid at the point $\langle x,y \rangle$ in the plane. Given the velocity field, you can find the \emph{flow lines} of the fluid -- the paths that fluid particles take.

\vfill

\begin{minipage}{0.45\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}
	[
		title={Velocity Field $\bfv(x,y) = y \ii  - x \jj$},
		view={0}{90},
		domain=-2:2,
		axis background/.style={fill=white}
	]
\addplot3[blue,quiver={u={x},v={-y},scale arrows=0.3},-stealth,samples=10]
		{0};
\end{axis}		
\end{tikzpicture} 
\end{minipage}
\quad
\begin{minipage}{0.45\textwidth}
\begin{tikzpicture}[scale=0.6]
\begin{axis}
	[
		title={Flow lines of Velocity Field}
	]
\foreach \r in {0.5,1,1.5,2}
{
		\addplot[no marks,red,domain=0.5:2,samples=41] 
			({x}, {\r/x});
		\addplot[no marks,red,domain=-2:-0.5,samples=41]
			({x}, {-\r/x});
		\addplot[no marks,red,domain=0.5:2,samples=41] 
			({x}, {-\r/x});
		\addplot[no marks,red,domain=-2:-0.5,samples=41]
			({x}, {\r/x});
}
\end{axis}
\end{tikzpicture}
\end{minipage}
\end{frame}

\begin{frame}
\frametitle{The Gradient Vector Field}
\footnotesize

If $f(x,y)$ is a function two variables, the \emph{gradient vector field}
$$ \nabla f (x,y) = \frac{\dee f}{\dee x}(x,y) \ii + \frac{\dee f}{\dee y} \jj $$
moves in the direction of greatest change of $f$

\bigskip

\begin{center}
\begin{tikzpicture}[scale=0.5]
\begin{axis}
	[
		title={$f(x,y) = x^2+y^2$},
		domain=-2:2,
		axis background/.style={fill=white}
	]	
		\addplot3[surf,
			domain=-2:2,samples=30,z buffer=sort]
			{x^2+y^2};
\end{axis}
\end{tikzpicture}
\qquad
\begin{tikzpicture}[scale=0.5]
\begin{axis}
	[
		title={$\nabla f (x,y)= (2x) \ii + (2y) \jj$},
		domain=-2:2,
		view={0}{90},
		axis background/.style={fill=white}
	]	
        \addplot3[blue,
            quiver={
             u={2*x},
             v={2*y},
             scale arrows=0.1,
            },
            -stealth,samples=15]
                {0};
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}
\frametitle{The Gradient Vector Field}
\footnotesize
If $f(x,y)$ is a function two variables, the \emph{gradient vector field}
$$ \nabla f (x,y) = \frac{\dee f}{\dee x}(x,y) \ii + \frac{\dee f}{\dee y}(x,y) \jj $$
moves in the direction of greatest change of $f$

\bigskip

\begin{center}
\begin{tikzpicture}[scale=0.5]
\begin{axis}
	[
		title={$f(x,y) = x e^{-x^2-y^2}$},
		domain=-2:2,
		axis background/.style={fill=white}
	]	
		\addplot3[surf,
			domain=-2:2,samples=30,z buffer=sort]
			{x*exp(-x^2-y^2)};
\end{axis}
\end{tikzpicture}
\qquad
\begin{tikzpicture}[scale=0.5]
\begin{axis}
	[
		title={$\nabla f (x,y) = (1-x^2) e^{-x^2-y^2} \ii + (-2xy) e^{-x^2-y^2} \jj$},
		domain=-2:2,
		view={0}{90},
		axis background/.style={fill=white}
	]	
        \addplot3[blue,
            quiver={
             u={exp(0-x^2-y^2)*(1-2*x^2)},
             v={exp(0-x^2-y^2)*(-2*x*y)},
             scale arrows=0.3,
            },
            -stealth,samples=15]
                {0};
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}
\frametitle{Mix and Match}
\footnotesize
Can you match these functions with the plots of their gradient vector fields?

\smallskip

\begin{enumerate}[A]
\item $f(x,y) = x^2 + y^2$   (has a global minimum)
\item	$f(x,y) = x^2 - y^2$    (has a saddle point)
\item	$f(x,y) = - (x^2+y^2)$  (has a global maximum)
\end{enumerate}

\vfill
\begin{center}
\begin{minipage}{0.25\textwidth}
\begin{tikzpicture}[scale=0.4]
\begin{axis}
	[
		title={$\nabla f (x,y)$ (sink)},
		domain=-2:2,
		view={0}{90},
		axis background/.style={fill=white}
	]	
        \addplot3[blue,
            quiver={
             u={-2*x},
             v={-2*y},
             scale arrows=0.3,
            },
            -stealth,samples=10]
                {0};
\end{axis}
\end{tikzpicture}
\end{minipage}
\qquad
\begin{minipage}{0.25\textwidth}
\begin{tikzpicture}[scale=0.4]
\begin{axis}
	[
		title={$\nabla f (x,y)$ (source)},
		domain=-2:2,
		view={0}{90},
		axis background/.style={fill=white}
	]	
        \addplot3[blue,
            quiver={
             u={2*x},
             v={2*y},
             scale arrows=0.3,
            },
            -stealth,samples=10]
                {0};
\end{axis}
\end{tikzpicture}
\end{minipage}
\qquad
\begin{minipage}{0.25\textwidth}
\begin{tikzpicture}[scale=0.4]
\begin{axis}
	[
		title={$\nabla f (x,y)$ (saddle)},
		domain=-2:2,
		view={0}{90},
		axis background/.style={fill=white}
	]	
        \addplot3[blue,
            quiver={
             u={2*x},
             v={-2*y},
             scale arrows=0.3,
            },
            -stealth,samples=10]
                {0};
\end{axis}
\end{tikzpicture}
\end{minipage}
\end{center}

\end{frame}


\section{Vector Fields in $xyz$-Space ($\R^3$)}

\begin{frame}
\frametitle{Vector Fields in Space}
\footnotesize
A \textbf{vector field} in space  is a function that associates to each $(x,y,z)$ a \emph{vector} 
$$\bfF(x,y,z) = P(x,y,z) \ii + Q(x,y,z) \jj+ R(x,y,z) \kk $$
We can visualize a vector field by a \emph{field plot}

\bigskip

\begin{center}
\begin{tikzpicture}[scale=0.75]
\begin{axis}
[
	domain=-1:1,
	xmin=-1,
	xmax=1,
	ymin=-1,
	ymax=1,
	zmin=-1,
	zmax=1,
	title={$\bfF(x,y,z) = x \ii + y \jj + z \kk$}
]
\foreach \z in {-1,-0.5,0,0.5,1}
{
	\addplot3[
		blue,
		quiver=
		{
			u={x},
			v={y},
			w={z},
			scale arrows=0.25,
		},
		-stealth, samples=5]
	(x,y,{\z});
}
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}
\frametitle{Vector Fields in Space}
\begin{center}
\begin{tikzpicture}
\begin{axis}
[
	axis equal,
%	view={60}{30},
	view={45}{30},
%	domain=-1:1,	
	domain=-2:2,
	xmin=-2,
	xmax=2,
	ymin=-2,
	ymax=2,
	zmin=-2,
	zmax=2,
	title={$\bfF(x,y,z) = y \ii + z \jj + x \kk$}
]
%\foreach \z in {-1,-0.66,-0.33,0.33,0.66,1}
{
\foreach \z in {-1.5, -1, 0, 1, 1.5}
	\addplot3[
		cyan,
		quiver=
		{
			u={y},
			v={z},
			w={x},
			scale arrows=0.25,
		},
		-stealth, samples=5]
	(x,y,{\z});
}
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}
\frametitle{Vector Fields in Physics}
\footnotesize
\begin{enumerate}
\item	The electric field generated by a point charge $q$ at the origin is
$$ \bfE(\bfx) = \frac{q \bfx }{ | \bfx |^3 } $$
\item	The gravitational force exerted on a mass $m$ at position $\bfx$
		by a mass $M$ at the origin is
$$ \bfF(\bfx) = -\frac{G M m \bfx}{|\bfx|^3} $$
\item	A \emph{conservative force} $\bfF$ is the gradient of a \emph{potential function}
$\varphi$, i.e.,
$$ \bfF = \nabla \phi $$
\end{enumerate}
\end{frame}

\begin{frame}
\frametitle{Magnetic Field Lines}

\vfill
\begin{center}
\href{https://www.youtube.com/watch?v=TsVZARGTRFc}{Watch A Video}
\end{center}
\vfill

\end{frame}




\end{document}
