% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2012_fall_practical_computing_for_scientists/hw09/hw09.tex"
% LAST MODIFICATION: "Mon, 05 Nov 2012 11:49:48 -0500 (evmik)"
% (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com>
% $Id:$
\documentclass[letter,12pt]{article}

%---------------------------------------------------------------
\usepackage{listings}
\usepackage{color}
\usepackage{fullpage}
%---------------------------------------------------------------

\begin{document}
\newcommand{\problem}[1]{%
	{\flushleft  \bf #1\\}
}
\newcommand{\hw}[1]{%
	\begin{center}
		\Large  \bf Homework #1%
	\end{center}%
}
\newcommand{\mat}[1]{% matlab code
{\color{blue}\texttt{#1}}%
}

%---------------------------------------------------------------
\hw{09}

General comments: 
\begin{itemize}
	\item Do not forget to run some test cases. 
\end{itemize}

\problem{Problem 1 (5 points)}
%---------------------------------------------------------------
A more realistic pendulum. 
Solve  numerically (using built-in \mat{ode45} solver) the following
physical problem of a pendulum motions
\begin{eqnarray*}
	\theta''(t) = - \frac{g}{L} \sin(\theta)
\end{eqnarray*}
Here $g$ is acceleration due to gravity ($g$=9.8 m/s$^2$), $L=1$ is the
length of the pendulum, and $\theta$ is angular deviation of the pendulum
from the vertical.

$\theta(0)$ assuming that initial angular velocity is zero
\begin{eqnarray*}
	\beta(0)=\theta'(0)=0
\end{eqnarray*}
Solve this problem (i.e. plot  $\theta(t)$ and $\beta(t)$) for two values of the
initial deflection $\theta(0)=\pi/10$ and $\theta(0)=\pi/3$.
Make sure to choose final time large
enough so you see at least 10 periods.
Show that period of the pendulum depends on the initial deflection.
Does is it takes longer to make one swing with larger or smaller initial
deflection?


\problem{Problem 2 (5 points)}
%---------------------------------------------------------------
Have a look at the predator and prey model (the \mat{ode\_predator\_prey\_model.m}
file provided with lecture 20 notes).

Find non trivial solution (i.e. $x_0 \ne 0$ and $y_0 \ne 0$) for which
population of wolves and rabbits is independent of time (i.e.
$dx/dt=dy/dt=0$). You should get a system of two linear equations which is
super simple, however I ask you to solve it using  matlab numerical solver
methods which we discussed during the lecture 21, i.e. form matrix A and column
B, and find x such that $A*x=B$.  Note: use constants a, b, c, and d provided
in matlab file.

So we see that it possible to have stable populations (or economy with out
ups and downs) but you need to be smart about initial conditions.

What is expected shape of the plot of the  wolves population vs  rabbits
with calculated above initial conditions? 
Plot it. 


\problem{Problem 3 (5 points)}
%---------------------------------------------------------------
It is possible to draw a parabola through any 3 point in a plane.
Using matlab linear equations solver find coefficients $a, b$ and $c$ for parabola
$y=a x^2 +b x +c$ which passes through points $p_1=(-10,10), p_2=(-2,12)$,
and $p_3=(12,10)$.

\problem{Problem 4 (5 points)}
%---------------------------------------------------------------
Using matlab \mat{interp1} with \mat{spline} method, find where
interpolation line crosses $y=0$ level. The interpolation is done over the
following points [(x,y) notation]: (2,10), (3,8), (4,4), (5,1), (6,-2).

Would it wise for above data point to search crossing with $x=0$ line? Why
so?


%---------------------------------------------------------------

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