% begin preamble
\documentclass[11pt,titlepage]{article}
\usepackage[margin=1in,noheadfoot]{geometry}
\usepackage[parfill]{parskip}
\usepackage{graphicx}
\usepackage[colorlinks,urlcolor=blue]{hyperref}
\usepackage{amssymb}
\usepackage{amsbsy}
\usepackage{wrapfig}

\newcommand{\e}[1]{\times 10^{#1}}
\newcommand{\q}{\mathrm}
\newcommand{\where}[1][where]{\qquad\mbox{#1}\qquad}
\newcommand{\bs}[1]{\boldsymbol{#1}}
\newcommand{\bh}[1]{\hat{\boldsymbol{#1}}}
\newcommand{\bv}[1]{\vec{\boldsymbol{#1}}}
\newcommand{\bt}[1]{\tilde{\boldsymbol{#1}}}
\newcommand{\ad}{^{\dagger}}
\newcommand{\flow}[1]{\mathcal{E}_{#1}}
\newcommand{\flux}[1]{\Phi_{#1}}
\newcommand{\dslash}{d \hspace{-0.5ex}\rule[1.2ex]{0.6ex}{.1ex}}
\newcommand{\ts}{\textsuperscript}
\def\rcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{ScriptR}}$}\!\!}}
\def\brcurs{{\mbox{$\resizebox{.16in}{.08in}{\includegraphics{BoldR}}$}\!\!}}
\def\hrcurs{{\mbox{$\hat \brcurs$}\!}}
%end preamble

\begin{document}
\begin{center}
  {\bf University of Kentucky, Physics 404G \\
    Homework \#1, Rev. B, due Thursday, 2020-08-27 }
\end{center}

\vspace{.3 in}

{\bf 1. Frog-Prince-Cannon}---A prince, out wandering in forest, got turned into a frog of mass 0.454~kg.  The object of this exercise is to safely return him from the swamp to his rightful place in the royal water fountain.  We will perform our task with a cannon placed 10~m outside the castle wall.  Since the prince is moderately afraid of heights, we will fire him through an opening in a window at an elevation of 5~m above swamp-level, with splash-down in the fountain, 4~m inside the wall, aligned horizontally with the window and cannon, at an elevation 1~m above the swamp.  To avoid a `pane'-full splat, please keep all tolerances within 10~cm.  Ignore the effects of wind velocity and air resistance.

{\bf \quad a)} Let's practice in Excel with a 1~lb cube of butter before putting anyone's life in peril.  Integrate the equations of motion step-by-step using the leap-frog technique [no pun intended]: for the differential equations $\dot{\bs{x}}=\bs{v}$ and $\dot{\bs{v}}=\bs{g}$, where $\bs g=[0,-9.81]~\q{m/s}^{2}$, starting from $\bs x_{0}=[0,0]~\q{m}$ and $\bs v_0=[5,14]~\q{m/s}$, calculate the new position and velocity $(\bs x, \bs v)$ after each time step of $\Delta t$=0.01~s, till at least $x=15~\q{m}$, a little past the target.  Tabulate each time step on a grid with columns $t$, $x$, $y$, $v_{x}$, $v_{y}$.  Update each new row from values of the previous one, starting with initial conditions on the first row.  Use the functions {\tt match} and {\tt index} to find the height $y_{1}$ at the wall ($x=10~\q{m}$), and $y_{2}$ at the fountain $(x=14~\q{m})$.  Adjust the {initial conditions so $[y_{1},y_{2}] = [5,1]~\q{m}$ within $10~\q{cm}$.}

{\bf \quad b)} Repeat in Matlab using expressions like {\tt v(end+1,:)=v(end,:)+$\ldots$} in a {\tt for} or {\tt while} loop to step through the trajectory.  Use the function {\tt max} to calculate the maximum height of the frog, and {\tt interp1} to calculate its position at the wall and fountain.  Type {\tt help interp1} for details.  Plot the frog's trajectory using {\tt plot(x,y)}, where {\tt x} and {\tt y} are column vectors of coordinates.

{\bf \quad c)} Use Matlab's {\tt ode45} function to automatically integrate the trajectory.  Create the file {\tt shoot.m} with a function {\tt yh = shoot(v0)}, where {\tt v0=[vx;vy]} (input) and {\tt yh=[y1;y2]} (output) are $2\times1$ column vectors.  Tune the initial conditions $\bs v_{0}$ by hand to obtain a safe splashdown in the fountain with target heights {\tt yt=[5;1]}.

{\bf \quad d)} Instead of solving the trajectory by guess work, we now implement the {\it Newton-Raphson method} [\href{http://apps.nrbook.com/c/index.html}{Numerical Recipes, \S 9.4}] to iteratively refine the input coordinates $\bs v_{0}$ leading to the desired output $\bs{y}_{t}$.  For each iteration, numerically calculate the {\it Jacobian matrix}, $\bs J = {\tiny \pmatrix{\partial y_{1}/\partial v_{x} & \partial y_{1}/\partial v_{y} \cr \partial y_{2}/\partial v_{x} & \partial y_{2}/\partial v_{y}}}$, of partial derivatives of the function {\tt shoot()}, such that $\bs{dy}_{h} = \bs J\, \bs{dv}_{0}$, to characterize the effect of adjusting the initial velocity by an arbitrary correction $\bs{dv}_{0}$.  Use it to tune $\bs{v}_{0}$ by the associated correction {\tt\ v0 = v0 + J\,\textbackslash (yt-shoot(v0))}, where the operator {\tt J\textbackslash dy} is shorthand for left division via the inverse matrix {\tt inv(J)*dy}.  Iterate to solve for $\bs v_{0}$ such that $\bs{y}_{h}(\bs{v}_{0})=\bs{y}_{t}$.

{\bf \quad e)} Perform the whole procedure automatically with Matlab's root-finding functionality using the command {\tt\ fsolve ( @(v)shoot(v)-yt, v0 )}, which finds the vector {\tt v0} such that {\tt shoot(v0)==yt}.  Can you solve the whole problem with one command?

\newpage

{\bf 2. Damped ballistic motion}---So far, we have neglected air resistance of our frog-prince's trajectory.  Assume a spherical frog of diameter $D=5~\q{cm}$, and mass $m=1~\q{kg}$.

{\bf \quad a)} Calculate the Reynolds number $R=Dv\rho/\eta$ for the initial muzzle velocity $v_{0}=10~\q{m/s}$, using the viscosity $\eta=1.7\times10^{-5}~\q{N\,s/m^{2}}$ and density $\rho=1.29~\q{kg}/\q{m}^{3}$ of air at STP, and decide whether to to use a linear $F_{lin}=3\pi\eta D v$ or quadratic $F_{quad}=\frac14 \rho A v^{2}$ drag force.  Calculate the terminal velocity $v_{ter}$.

{\bf \quad b)} Repeat the simulation including air resistance, using the same initial conditions as tuned in H01.  Does he still make it?  Determine the initial velocity and direction required to safely land the frog-prince, accounting for air resistance.  [bonus: Plot and compare the trajectories with and without resistance; including both numerical and analytic solutions on the same graph.]

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
