% -*- latex -*-
% FILE: "/home/evmik/jobs/wm/2011_fall_practical_computing_for_scientists/hw08/hw08.tex"
% LAST MODIFICATION: "Tue, 08 Nov 2011 11:40:52 -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{08}

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

\problem{Problem 1 (5 points)}
%---------------------------------------------------------------
Solve  numerically (using built-in \mat{ode45} solver) the following physical problem if the oscillatory motion
\begin{eqnarray*}
	x''(t) = - x(t)^p 
\end{eqnarray*}
with following initial conditions
\begin{eqnarray*}
	x(0)=0 \\
	v(0)=x'(0)=v_0
\end{eqnarray*}
Here the $x$ is position of the  particle, $t$ is time , $v$ is velocity,
$v_0$ is initial velocity, and $p$ is a parameter which takes odd values.

When $p=1$ the problem resembles the equation of motions for the well known
harmonic oscillator with $k/m=1$.

Solve this problem (i.e. plot  $x(t)$ and $v(t)$) for two values of the
parameter $p=1$ and $5$,  and  the initial velocity
$v_0=1$. Make sure to choose final time large
enough so you see at least 10 periods.

\problem{Problem 2 (5 points)}
%---------------------------------------------------------------
Show that the period of the oscillation is independent of $v_0$ for the
harmonic oscillator and  depends on $v_0$ for the case of $p=5$. 
Do it for at least five different values of $v_0$ to convince yourself.



\problem{Problem 3 (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 4 (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)$.

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

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