%Plotting Solutions to First Order Initial Value Problems
%If you modify this file, please note it here and in the footnote below.
%Math340

\documentclass[12pt]{article}
\usepackage{times}
\pagestyle{empty}

\addtolength{\textwidth}{1.2in}
\addtolength{\textheight}{1.2in}
\addtolength{\oddsidemargin}{-.58in}
\addtolength{\evensidemargin}{-.58in}
\renewcommand{\baselinestretch}{1.0}
\parindent = 0cm
\parskip = .1cm

\begin{document}

\begin{center}
{\Large
Plotting Solutions to First Order Initial Value Problems
\footnote{Copyright \copyright 2002 Steve Chapin and Larry Snyder.
All rights reserved. Please address comments to young@math.ohiou.edu.}}
\end{center}

Enter the following sequence of commands:\\
   \verb&   F = inline('sin(y)', 't', 'y')&  \dotfill Defines a function of two variables. \\
   \verb&   T = 0:.01:10;&  \dotfill Defines a vector. Do not skip the semicolon.\\
   \verb&   [T, Y] = ode45(F, T, 1);&   \\
   \verb&   plot(T, Y)& 

\medskip

\textbf{Remarks}

\smallskip

1. If you skip the semicolon, you will get a list of the values in T.

\smallskip

2. The third statement tells \textsc{MatLab} to numerically solve the IVP: 
$$
	y' = F(t, y), \quad y(0) = 1.
$$
By using T as the second argument in the call to \verb& ode45 & 
we are indicating that we want the values of Y at the times 
given in the vector T.  If you want more info on the use 
of \verb& ode45&, issue the command \verb& help ode45&.

\smallskip

3. The fourth statement plots a graph of the points 
$$
	(T(1), Y(1)), (T(2), Y(2)), \ldots, (T(1000), Y(1000)).
$$
  It should appear that the solution has a horizontal asymptote.  
Try extending the range of the $t$ values to go from 0 to 20.  
You can re-type the second statement as
\verb& T = 0:.01:20; & or you can use the up-arrow key until the statement
\verb& T = 0:.01:10; & reappears and then use the left-arrow key to move the
cursor left and change the 10 to 20,  then press the Enter key.  Next
you can again use the up-arrow key to recall \verb& ode45& and then 
press the Enter key.  Plot the new values. The up-arrow key and the 
down-arrow key allow the user to move up and down through the list of 
previous commands.  A command does not get entered until you press the Enter key.

\smallskip

4. What would you guess for the value of the horizontal asymptote?

\medskip

Using the methodology described above, sketch \emph{by 
hand}, on a separate piece of paper, the solution of the given initial-value 
problem on the given interval.  DO {\bf not} get a printout.

Make sure you include appropriate numerical values along the axes.
\begin{enumerate}
\item  \quad 
	$y' = \frac{1}{2} - \cos t, \qquad y(0) = 1, \qquad [0, 30]$

\item \quad 
	$\frac{dy}{dt} = \frac{2}{t+1} - y^2, \qquad y(0) = 2, \qquad [0, 30]$

\item \quad 
	$y' - y = t \cos t, \qquad y(0) = 0, \qquad [0, 20]$

\item \quad 
	$t\frac{dy}{dt} + y = t, \qquad y(1) = 2, \qquad [1, 10]$

\end{enumerate}

\end{document}
