% Everything from the top of the file to the \begin{document} is
% called the preamble.  It contains information used to set up 
% the document.


\documentstyle[12pt,epsf]{article}  % [12pt] sets the default font size
				    % [epsf] includes the encapulated post-
				    % script library
\setlength{\oddsidemargin=+0.5in}   % shifts the margin in 0.5 inches
\setlength{\textwidth=6.0in}        % makes the width of the text 6.0 inches
\setlength{\topmargin=+0.0in}	    % shifts the topmargin my 0.0 inches
\setlength{\textheight=8.25in}	    % changes the text height to 8.25 inches

% This is a comment

%\renewcommand{\baselinestretch}{1.5} changes the spacing to 
% halfway between single and double spacing.

%Here are some macros
\newcommand{\DD}[2]{\frac{d#1}{d#2}} % This is a first derivative
\newcommand{\DDtwo}[2]{\frac{d^2 #1}{d {#1}^2}} % This is a second derivative.
% the [2] is an optional command meaning that there will be two arguments.

\newcommand{\beq}{\begin{equation}}
\newcommand{\eeq}{\end{equation}}

%no more macros


\pagestyle{empty} % nothing will be printed in the header or footer.



\begin{document} % This is where the document starts.


{\noindent {\Large {\bf Numerical Analysis APPM 5610}}}

% \noindent starts the text at the right margin
% \Large changes the font to a larger size
% \bf changes the font to boldface

\begin{center}
Assignment 1--due February 7, 1994
\end{center}

\vspace{0.4in}  %inserts 0.4 inches of blank white space.

{\bf Problem 3.}

I wrote a routine to solve first order % Notice that this line is indented
% and that there is no break between the words order and ordinary.
ordinary differential equations in two 
dimensions using the trapezoidal method, which is

\[ % begin centered math mode
y_{n+1}=y_n+\frac{h}{2}(f(x_n,y_n)+   % y_{subscript} 
f(x_{n+1},y_{n+1})) 			% \frac{numerator}{denominator}
\] % end centered math mode

with $y_n, y_{n+1}$ both two-dimensional   % $ this is within-text math mode.$
vectors which depends on $x$ ($y_{n+1}\equiv % \equiv is one of many math 
y(x_{n+1})$).  This is a implicit method 	% symbols.
with 2nd order accuracy.

To solve the implicit scheme, I used the 
following non-linear solver.  The initial 
guess for $y_{n+1}^{(0)}=y_n+hf(x_n,y_n)$, % y^{superscript}
and the iteration is

\begin{equation}   y_{n+1}^{(j+1)}=y_{n+1}^{(j)}+\frac{h}{2}
(f(x_n,y_n)+f(x_{n+1},y_{n+1}^{(j)}) 
\label{nl_solver} % names the equation.
\end{equation}    %begin and end equation puts down equation numbers

The local error of the trapezoidal method, 
which is true solution, $Y(x)$, after one 
step minus predicted solution, $y(x)$, is:
\[	
Y(x)-y_n(x)=-\frac{1}{12}h^3y_n'''-\frac{1}
{24}h^4y_n^{(4)}+O(h^5)
\]

The global error, then, is of order $h^2$, 
therefore, the error can be expressed as:
\[Y(x)-y_n(x)=k_2h^2+k_3h^3+\cdots \] % \cdots gives three dots centered in 
					% the line.
Richardson extrapolation can then be used 
on the error of the above form to find a 
higher order method.

\vspace{0.2in}

{\bf Examples}

The initial value problem:
\beq 			% \beq is the macro for \begin{equation}
y''=-y ~~~~~~  y(0)=1	% ~ puts space in equations or text.	
\label{IVP}		% labels this equation as an IVP
\eeq			% \eeq is the macro for \end{equation}
can be reduced to a first order initial % c=centered r=right l=left
value problem in two dimensions and is  
of the form:

\begin{eqnarray*}  % \begin{eqnarray*} starts math mode and  centers
\DD{y_1}{x}=y_2 & & y_1(0)=1  \\  % everything around the characters
\DD{y_2}{x}=-y_1 & & y_2(0)=0 \\  % between the &  & .  The \\ indicate
\end{eqnarray*} 		  % end of line.  * means no line number.

which has the solution $y(x)=\cos(x)$.  
Figure \ref{err_fxn}   		% pointer to the label err_fxn
shows the error function, the 
numerical solution minus the actual solution.  

\begin{figure}  % starts a figure

\epsfxsize=4in  % sets the size of the eps plot to 4 in wide.
\centerline{ \epsffile{plot.eps}}  % centers the plot in the file plot.eps.

\caption{This is the error function for the solution in Problem 3.} 
		
\label{err_fxn}  % names the figure
\end{figure}



The second example is the initial value problem: 
\[ 
y''+1001y'+1000y =0
\] 
which is a good example of a stiff system.   
This can be reduced to: 

\begin{eqnarray*} 
\DD{y_1}{x}=y_2 & & y_1(0)=1 \\
\DD{y_2}{x}=-1001y_2-1000y_1 && y_2(0)=-1  
\end{eqnarray*} 

The general solution of this equation is  
$A \exp(-x)+B \exp (-1000x)$. 
  The solution to the equation with the  
given initial conditions is  
$y(x)=\exp(-x)$.  I started with the step 
 size $h=0.1$, but convergence 
 was {\em very} slow.  The step size $h=0.01$,  
was much better, but still 
 not fast.  (Typically 10 iterations of  
Richardson extrapolation was required 
 to get miminum accuary of $10^{-5}$.   
The previous example only required 3  
iterations to get $10^{-10}$ accuracy.) 

Typically, implicit methods are very 
good methods to use to solve stiff systems.  
However, the nonlinear solver that I used 
does not always converge or converge quickly 
in a stiff problem.  Some of the possible 
solution would be to use a higher order 
nonlinear equation solver, such as a 
Newton-Raphson type method.

\end{document}










