\documentclass[english,compress]{beamer}
\usepackage{mathptmx}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% this default might be overridden by plain title style
\newcommand\makebeamertitle{\frame{\maketitle}}%
% (ERT) argument for the TOC
\AtBeginDocument{%
  \let\origtableofcontents=\tableofcontents
  \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
  \def\gobbletableofcontents#1{\origtableofcontents}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usetheme{Dresden} %Dresden, AnnArbor
%\useoutertheme{sidebar}
\usecolortheme{default} %default, crane, beaver
\usefonttheme{professionalfonts} % using non standard fonts for beamer
\usefonttheme{serif} % default family is serif
%\usepackage{fontspec}
%\setmainfont{Liberation Serif}
% or ...

\setbeamercovered{transparent}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{multimedia}
%\usepackage{media9}
%\usepackage{media15}

\makeatother

\usepackage{babel}
\begin{document}
\global\long\def\pd#1#2{{\frac{\partial#1}{\partial#2}}}%
\global\long\def\pds#1#2#3{{\frac{\partial^{#3}#1}{\partial#2^{#3}}}}%

\global\long\def\diff#1#2{{\frac{d#1}{d#2}}}%
\global\long\def\diffs#1#2#3{{\frac{\partial^{#3}#1}{\partial#2^{#3}}}}%

\global\long\def\dt{\Delta t}%
\global\long\def\dx{\Delta x}%
\global\long\def\dr{\Delta r}%

\title[Introduction to Modeling with Differential Equations]{Introduction to Modeling}
\author[www.simiode.org]{SIMIODE Remote Teaching Modules}
\institute[Presentation Produced with Support from NSF Award \#1940532]{\includegraphics[height=2cm]{NSF_logo.jpeg}Award \#1940532\hfill\includegraphics[height=2cm]{simiode_logo}
}
\date{{}}

\makebeamertitle

\pgfdeclareimage[height=1cm]{institution-logo}{NSF_logo.jpeg}



\AtBeginSubsection[]{%
  \frame<beamer>{ 
    \frametitle{Outline}   
    \tableofcontents[currentsection,currentsubsection] 
  }
}

%\beamerdefaultoverlayspecification{<+->} % Uncomment to pause at each bullet point

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Modeling Project Preview}
{\em Simulating the spread of the common cold throughout a residence hall using markings on a floorplan, while investigating the effectiveness of social/hygienic behaviors in slowing the spread}

\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{BrandtHallFloorPlan_cropped.jpg}
		\par\end{centering}
	\end{figure} 
\begin{itemize}
\item R.C. Harwood (2016), ``1-037-S-CommonColdSpread,'' http://www.simiode.org/resources/3171. (Student Version)
\item RMT IntroModeling SimulationGuide.pdf (Handout of instructions for remote simulation)
\end{itemize}
\end{frame}

\begin{frame}{Modeling Project Preview}
{\em ``Although to penetrate into the intimate mysteries of nature and thence to learn the true causes of phenomena is not allowed to us, nevertheless it can happen that a certain fictive hypothesis [model equation] may suffice for explaining many phenomena.''--L. Euler
}

Questions we seek to answer with a fitting model equation:
\begin{itemize}
\item How does the number of residents infected, x(t), vary with time? 
\item How effective are social/hygienic responses? 
\item How does our analysis for the common cold inform our preparation for more serious diseases?
\end{itemize}
\end{frame}

\begin{frame}{Modeling Project Preview}
{\em Demonstration of Some Social/Hygienic Responses}
\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{BrandtHallFloorPlan_cropped.jpg}
		\par\end{centering}
	\end{figure}
Simulation Scenarios:
\begin{itemize}
\item Normal Behavior (Control)
\item A: Surface Sterilization Response
\item B: Reduced Exposure Response
\item Both A \& B
\end{itemize}
\end{frame}

\begin{frame}{Modeling Project Preview}
{\em Project Template Spreadsheet}
\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{spreadsheet_ProjectPreview_setup.png}
		\par\end{centering}
	\end{figure}
Questions to guide our modeling of the data:
\begin{itemize}
\item What pattern does this model equation describe?
\item What is important about this model?
\item What does the data look like?
\item How well does this model fit the data?
\end{itemize}
\end{frame}

\begin{frame}{Outline}

\tableofcontents{}

\end{frame}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Interpretation}
\begin{frame}{What is a Differential Equation Model?}
{\em The embodiment of a dynamic pattern which allow us to predict the future \\Knowing multiple ways to interpret a differential equation can help you solve/analyze it effectively and skillfully apply it as a model.}
\begin{description}
\item [{Equation:}] An equation involving one or more derivatives of an
unknown variable

\item [{Description:}] A described pattern of how a quantity relates to its rates of change

\item [{Family:}] A relation between a family of solutions ({\em general solution}) and their derivatives

\item [{Fit:}] A derivative relation for a function ({\em specific solution}) which fits an additional condition(s) 
\end{description}
\end{frame}

\begin{frame}{Example}

\begin{description}
\item [{Equation:}]
\[
x'+4x=0\iff \frac{dx}{dt}=-4x
\]
\item [{Description:}] Rate of change is negatively proportional to the amount

\begin{itemize}
\item \emph{How does the amount $x(t)$ change over time?}
\item \emph{Can you think of a function whose 1st derivative is the same
function multiplied by -4?}
\item \emph{Can you think of any others? If so, how are they related?}
\end{itemize}
\end{description}
\end{frame}

\begin{frame}{Example}
\begin{description}
\item [{Family:}]
\begin{align*}
x & =Ce^{-4t}\\
x' & =-4Ce^{-4t}\\
x'+4x & =\left(-4C+4C\right)e^{-4t}=0
\end{align*}
\item [{Fit:}]
\[
x'+4x=0,\ x(0)=2
\]
\begin{align*}
x(0) & =C=2\\
\implies x(t) & =2e^{-4t}
\end{align*}
\end{description}
\end{frame}

\begin{frame}{Exponential Growth/Decay Model}
\begin{description}
\item [{Equation:}]
\[
P'-rP=0\iff \frac{dP}{dt}=rP
\]
\end{description}
with growth/decay rate $r$ and population $P(t)$
\begin{description}
\item [{Description:}] Rate of change is proportional (by $r$) to the population
\item [{Family:}]
\[
P=Ce^{rt}
\]

\item [{Fit:}]
\[
P'=rP,\ P(0)=P_{0}
\]
\begin{align*}
\implies P(t) & = P_{0}e^{rt}
\end{align*}

\end{description}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Characterization}
\begin{frame}{Characterization of Differential Equations}
{\em Key characteristics determine the validity of solution methods and analytical techniques}
\begin{description}
\item [{Order}] Integer of the highest derivative in the equation
\item [{Linear?}] If all unknown terms are raised to the 1st power, scaled,
and added together
\item [{Homogeneous?}] If all added terms in the equation are unknown
\item [{Autonomous?}] If the equation is not explicitly defined by the independent
variable $(t)$
\end{description}
{\em Characterize the following model equations}
\begin{enumerate}
\item $\frac{dP}{dt}=rP\left(1-\frac{P}{N}\right)-h$
\item $mx''+k\left(x'\right)^p=\frac{mMG}{(R+h-x)^2}$
\item $\frac{dA}{dt}=ac-b\left(\frac{A}{V+\left(a-b\right)t}\right)$
\end{enumerate}
\end{frame}


\begin{frame}{1. Logistic Growth with Harvesting Model}
\[
\frac{dP}{dt}=\left(r\left(1-\frac{P}{N}\right)\right)P-h  \iff \textrm{Rate of Change = Input - Output}
\]
with exponential growth rate $r$, carrying capacity $N$, harvesting rate $h$, and population $P(t)$.
\begin{itemize}
\item \emph{1st order, nonlinear, nonhomogeneous, and autonomous (assuming
constant parameters)}
\item Description: {\em A population's rate of change is equal to the balance between \\
logistic growth input, proportional to population but constricted by a carrying capacity, and \\
a constant harvesting rate output.}
\end{itemize}

\end{frame}

\begin{frame}{2. Gravitational Motion Model (Falling)}
\[
mx''=\frac{mMG}{(R+h-x)^2} - k\left(x'\right)^p \iff ma=\sum F=F_g + F_d
\]
with object's mass $m$, mass of the Earth $M$, universal gravitational constant $G$, radius of the Earth $R$, initial altitude $h$, drag coefficient $k$, power $p$, and altitude traveled $x(t)$.
\begin{itemize}
\item \emph{This model is 2nd order, nonlinear, homogeneous, and autonomous (assuming constant parameters)}
\item Description: {\em A falling object's acceleration is proportional to the sum of the forces of: \\gravitational attraction (inverserly proportional to the square of the distance between centers of mass) and \\drag (negatively proportional to the powered velocity).}
\end{itemize}
\end{frame}

\begin{frame}{2. Simplified Gravitational Motion Model (Falling)}
\[
m\frac{d^{2}x}{dt^{2}}=mg-k\left(\frac{dx}{dt}\right)^{p}\iff m\frac{dv}{dt}=mg-kv^{p}
\]
with mass $m$, gravitational acceleration constant $g$, drag coefficient $k$, power $p$, altitude traveled $x(t)$, and velocity of descent $v(t)$.
\begin{itemize}
\item \emph{This model is 1st order for v (but 2nd order for x), (non)linear (depends on $p$), nonhomogeneous, and autonomous (assuming constant parameters)}
\item Description: {\em A falling object's acceleration is proportional to the sum of the forces of: \\gravitational attraction (approximately constant) and \\drag (negatively proportional to the powered velocity).}
\end{itemize}
\end{frame}

\begin{frame}{3. Single Compartment Mixing Model}
\[
\frac{dA}{dt}=ac-\left(\frac{b}{V+\left(a-b\right)t}\right) A \iff \textrm{Rate of Change = Input - Output}
\]
with flow rate in $a$, flow rate out $b$, material concentration
flowing in $c$, initial volume $V$ of tank, and amount of material
$A(t)$ in the mixed tank 
\begin{itemize}
\item \emph{This model is 1st order, linear, nonhomogeneous, and not autonomous
(unless $a=b$ and parameters are constant)}
\item Description: {\em The amount of pollutant material in a mixture changes based upon the balance of \\
constant input flow and \\
output flow proportional to the current amount.}
\end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Visualization}
\begin{frame}{Graphing a First Order Differential Equation}
{\em Crucial understanding of a differential equation model can be found more readily in visualizations of the shape and behavior than the algebraic form of the solution.}
\begin{itemize}
\item Phase line by hand
\item Slope field using DFIELD
\end{itemize}
\end{frame}

\begin{frame}{What is a Phase Line?}
{\em If the equation is autonomous, $x'=f(x)$, then the vertical sign chart of the slope (phase line) guides us in sketching the shape of the family of solutions.}
\begin{enumerate}
\item Find all equilibrium points $x=E$ where $x'=f(E)=0$
\item Create a vertical sign chart for $f(x)$ about these $E$ points
\item Draw the time axis and sketch the family of solutions by following the signs
\end{enumerate}
\end{frame}

\begin{frame}{Example Phase Line}
{\em Single Compartment Mixing Model (Steady Volume): $a=b,c,V>0$}
\[
x' = ac-a\frac{x}{V}
\]
\begin{enumerate}
\item Eq. pt. $x=$
\item Create a vertical sign chart:
\item Sketch family of solutions:
\end{enumerate}
{\em Now, use your sketch and what you know about the exponential growth/decay model to write down the family of solutions and then fit it to $x(0)=x_0$.}
\end{frame}

\begin{frame}{What is a Slope Field?}
{\em For differential equation, $x'=f(t,x)$, the slopes of the family of solutions can be scaled and plotted at discrete points to show the direction of any solution (slope field or direction field).}
\begin{enumerate}
\item Use software to plot direction vectors $<1,f(t,x)>$ at various points $(t,x)$, scaling the vectors to fit
\item Plot initial condition point $(t_0,x_0)$ and sketch the solution through it which follows the arrows
\end{enumerate}
\end{frame}

\begin{frame}{DFIELD Software}
{\em dfield is an example free software for plotting the slope/direction field}
\begin{figure}
\begin{centering}
\includegraphics[width=0.9\textwidth]{dfield_mixing_setup.png}
\par\end{centering}
\caption{http://www.cs.unm.edu/~joel/dfield/\qquad\qquad\qquad}
\end{figure}
\end{frame}

\begin{frame}{Example Slope Field}
{\em Single Compartment Mixing Model (Steady Volume): $a=b=2$ l/min, $c=3$ g/l, and $V=150$ l}
%\[
%x' = ac-a\frac{x}{V},\ x(0)=50\ g;\ a=2\ l/min, c=3\ g/l, V=150\ l
%\]
	\begin{figure}
		\begin{centering}
			\includegraphics[width=0.9\textwidth]{dfield_mixing_SteadyVol_blank.png}
		\par\end{centering}
		\caption{Sketch the solution}
	\end{figure}
\end{frame}


\begin{frame}{Example Slope Field}
{\em Single Compartment Mixing Model: $a=1.5$ l/min, $b=2$ l/min, $c=3$ g/l, and $V=150$ l}
%\[
%x' = ac-b\frac{x}{V+(a-b)t}, x(0)=50\ g;\ a=1.5\ l/min, b=2\ l/min, c=3\ g/l, V=150\ l
%\]
	\begin{figure}
		\begin{centering}
			\includegraphics[width=0.9\textwidth]{dfield_mixing_blank.png}
		\par\end{centering}
	\caption{Sketch the solution}
	\end{figure}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Evaluation}
\begin{frame}{Evaluation of Numerical Solution and Model Fit to Data}
{\em Knowing how computed error of a numerical solution accumulates can help us fit our model to the noise inherent in data.}
\begin{itemize}
\item Evaluating a Numerical Solution
\item Fitting a Model to Data
\end{itemize}
\end{frame}

\begin{frame}{What is a Numerical Solution?}
{\em Arithmetic computations that approximate the calculus of a differential equation \\Caution: key characteristics may be preserved, but the accumulated errors can blur them.}
{\bf Euler's Method} \\
Given $t_0,x_0$ to solve $x' = f(t,x),x(t_0)=x_0$, choose $\dt,n$.\\
for k = 0 to n-1
\begin{itemize}
\item $x_{k+1} = x_k + \dt f(t_k,x_k)$ <-- "Next = Current + Portion of Slope"
\item $t_{k+1} = t_k + \dt$
%\item $x(t+\dt)=x(t)+\dt f(t,x(t))
%\item $t = t + \dt$
\end{itemize}
end
\end{frame}

\begin{frame}{Example Numerical Solution}
	\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{spreadsheet_Euler_mixing_setup.png}
		\par\end{centering}
	\end{figure}
\end{frame}

\begin{frame}{Example Numerical Solution}
	\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{spreadsheet_Euler_mixing_graphs.png}
		\par\end{centering}
	\end{figure}
\end{frame}

\begin{frame}{Model Fit to Data}
{\em Investigating a model's qualitative and quantitative fit begins with visualization.} 
\begin{itemize}
\item Graph various model equations to match shape of $x$ data
\item Plot $x'$ data vs $x$ data to visualize autonomous model $x'=f(x)$
\item Plot $x'$ data vs model slope $f(t,x)$ of data for 1:1 linear regression
\item Plot model solution $x(t)$ and data $x$ vs. time $t$ and minimize error
\end{itemize}
\end{frame}

\begin{frame}{Example Fitting of Model to Data}
	\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{spreadsheet_Data_mixing_setup.png}
		\par\end{centering}
	\end{figure}
\end{frame}

\begin{frame}{Fit Model Shape}
{\em Match the shape of the model slope function to the derivative pattern in the data}
	\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{spreadsheet_Data_mixing_graphs.png}
		\par\end{centering}
		\caption{Qualitatively fit shape and quantitatively fit data's change to value.\\Equilibrium point: $cV \approx 200$. Slope function: $ac-\frac{a}{V}x=3.12-0.0161x$.\\
Given $V=100$, compute $c\approx 2$ and estimate $a\approx 1.56$ or $1.61$.}
	\end{figure}
\end{frame}

\begin{frame}{Fit Model Parameters}
{\em Weave the chosen model shape through the data values}
	\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{spreadsheet_Data_mixing_setup.png}
		\par\end{centering}
		\caption{Given $V=100$, equilibrium of data ($c=2$), and slope function. \\ Update the value of $a$ near $1.56$ and $1.61$ to minimize RMSE (maximize $R^2$).}
	\end{figure}
\end{frame}
	
	
	
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\appendix
\section*{Appendix}

\begin{frame}{Modeling Project Review}
{\em Simulating the spread of the common cold throughout a residence hall using markings on a floorplan, while investigating the effectiveness of social/hygienic behaviors in slowing the spread}

\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{BrandtHallFloorPlan_cropped.jpg}
		\par\end{centering}
	\end{figure} 
\begin{itemize}
\item How does the number of residents infected, x(t), vary with time? 
\item How effective are social/hygienic behaviors? 
\item How does our analysis for the common cold inform our preparation for more serious diseases?
\end{itemize}
\end{frame}
	
\begin{frame}{Misleading Fit}
{\em Caution! Due to low number of data points, a bad model can still fit data surprisingly well.}
	\begin{figure}
		\begin{centering}
			\includegraphics[width=1\textwidth]{spreadsheet_ProjectPreview_modelfit.png}
		\par\end{centering}
		\caption{Model fit of data with low RMSE and very high $R^2$, but where shape fit is poor.}
	\end{figure}
\end{frame}

\begin{frame}{Misleading Fit}
{\em Patterns in the data's derivative shows how bad our model was in form.}
	\begin{figure}
		\begin{center}
			\includegraphics[width=1\textwidth]{spreadsheet_ProjectPreview_slopefit.png}
		\end{center}
		\caption{Linear pattern in slope function is an incorrect shape and makes a poor fit of the data's derivative.}
	\end{figure}
\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{frame}{Supplemental Resources for {\bf Introduction to Modeling}}
\begin{itemize}
	\item Project: R. Corban Harwood (2016),\\
{\em 1-037-S-CommonColdSpread,} www.simiode.org/resources/3171\\
{\em 1-037-T-CommonColdSpread,} www.simiode.org/resources/3172
	\item Instructional Videos: SIMIODE Channel on YouTube
	\item All Module Materials for Teachers: www.simiode.org/modules
	\begin{itemize}
		\item Guide for implementing instructional videos and activities
		\item Adaptable source material for slides and handouts
		\item Assessment guide with learning goals, examples, and rubrics
	\end{itemize}
\end{itemize}
Send questions about {\bf Introduction to Modeling} to \\
\centering{ Corban Harwood, Prof. of Mathematics at George Fox U.\\ rharwood@georgefox.edu}
\end{frame}

\begin{frame}{More Teaching Resources Available at SIMIODE}
{\em The Systemic Initiative for Modeling Investigations and Opportunities with Differential Equations (SIMIODE) is a community of educators and students with a common interest in model-driven activity-based learning of differential equations.}
\begin{itemize}
\item FREE registration is available for all educators
\begin{itemize}
\item FREE access to adaptable Open Education Resources (OER)
\item www.simiode.org/register
\end{itemize}
\item Student Challenge in Undergraduate Differential Equations Modeling (SCUDEM)
\begin{itemize}
\item Hosted by regional host sites (online for November 2020!)
\item www.simiode.org/scudem
\end{itemize}

\end{itemize}




\end{frame}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Extra Example Slides
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{Example 2}

\begin{description}
\item [{Equation:}]~
\[
x''+4x=0\iff \frac{d^2x}{dt^2}=-4x
\]
\item [{Description:}]~
Acceleration is negatively proportional to the position.
Also, concavity is negatively proportional to function value.

\begin{itemize}
\item \emph{How does the position $x(t)$ change over time?}
\item \emph{Can you think of a function whose 2nd derivative is the same
function multiplied by -4?}
\item \emph{Can you think of any others? If so, how are they related?}
\end{itemize}
\end{description}
\end{frame}

\begin{frame}{Example 2}
\begin{description}
\item [{Family:}]~
\begin{align*}
x & (t)=C_{1}\cos\left(2t\right)+C_{2}\sin\left(2t\right)\\
x'' & (t)=-4C_{1}\cos\left(2t\right)-4C_{2}\sin\left(2t\right)\\
x''+4x & =\left(-4C_{1}+4C_{1}\right)\cos\left(2t\right)+\left(-4C_{2}+4C_{2}\right)\sin\left(2t\right)=0
\end{align*}
\item [{Fit:}]~
\[
x''+4x=0,\ x(0)=2,\ x'(0)=-2
\]
\begin{align*}
x(0) & =C_{1}+0=2\\
x'(0) & =0+2C_{2}=-2\\
\implies x(t) & =2\cos\left(2t\right)-\sin\left(2t\right)
\end{align*}
\end{description}
\end{frame}

\begin{frame}{Model 2: Simple Harmonic Oscillator}
\begin{description}
\item [{Equation:}]~
\[
mx''+kx=0\iff mx''=-kx
\]
\end{description}
with mass $m$, spring constant $k$, and displacement $x(t)$ 
\begin{description}
\item [{Description:}]~
\[
\text{Force is negatively proportional to displacement}
\]
\item [{Family:}] 
\[
x(t)=C_{1}\cos\left(\omega t\right)+C_{2}\sin\left(\omega t\right),\ \omega=\sqrt{\frac{k}{m}}
\]
\item [{Fit:}]~
\[
mx''+kx=0,\ x(0)=x_{0},\ x'(0)=v_{0}
\]
\[
\implies x(t)=x_{0}\cos\left(\omega t\right)+\frac{v_{0}}{\omega}\sin\left(\omega t\right)
\]
\end{description}
\end{frame}





\end{document}%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
