% Euler's Method
% MATH 266B Exercise 4
\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 Euler's Method
\footnote{Copyright \copyright 2003 Winfried Just, Department Mathematics,
Ohio University. All rights reserved.}}
\end{center}
In this exercise, we will do some experiments to visualize the workings of Euler's method.
You may submit it on Tuesday for three bonus points.
You should prepare a worksheet with the answers to all questions posed below for submission.\\
For this exercise, you need to download the file Euler.m from my web page and save it in
the ``work'' directory of your \textsc{MatLab} folder without changing its name (and without changing
the extension .m)!\\
First let us explore Euler's method for the autonomous differential equation
$\frac{dy}{dt} = y$. Suppose you want to approximate $y(2)$ for the solution $y(t)$ of this
equation that takes the initial value $y(0) = 1$.\\
Enter:\\
\verb$>> Euler$
\\At the next prompt enter:\\
\verb$>> y$\\
As we discussed in class, the solution $y(t)$ that we want to approximate is given by the formula\\
$y(t) = e^t$. Therefore, at the next prompt enter:\\
\verb$>> exp(t)$\\
At the next prompts enter \verb& 0 & for \verb&a&, \verb& 1 & for \verb& y(a)&,
and \verb& 2 & for \verb& b &.
Finally, the program will prompt you to enter $\Delta t$. First try
$\Delta t = 0.5$. The figure shows you the graph of the function and the graph of
the approximations. Look closely and convince yourself that the approximations are
a piecewise linear function. \textsc{MatLab's} Command Window will show you the error
$y(2) - \hat{y}(2)$ and prompt you for another $\Delta t$.
\begin{enumerate}
\item What errors does \textsc{MatLab} give you for $\Delta t = 0.5$, $\Delta t = 0.1$,
and $\Delta t = 0.01$?\\
Now let us consider the initial value problem $\frac{dy}{dt} = 2ty$;
$y(0) = 1$. It can be easily verified that the solution of this initial value problem is
$y(t) = e^{t^2}$.
Let us use the program ``Euler'' to find approximations of $y(2)$ for this solution. Follow similar
steps as before. Recall that you should enter the right-hand side of your differential equation as:\\
\verb$>> 2*t*y$
\item What errors does \textsc{MatLab} give you for $\Delta t = 0.5$, $\Delta t = 0.1$, and
$\Delta t = 0.01$?
\item Why are the errors so much bigger than for the previous example?
\end{enumerate}
\end{document}