Math 2250 Lab 2
 Two Numerical Methods for Solving Differential Equations
             
 Section 1.4 in your book is titled Approximation Methods: Numerical Analysis.  An entire field of mathematics, "numerical analysis" deals with approximating solutions. The purpose of this lab is to acquaint you with a basic method used to approximate solutions of differential equations, and let you visualize graphically what the method does. Background material is found in section 1.4 (Euler’s method) of your text and will be discussed in class. Here is a review:

Both methods below are applicable to a 1st order differential equation of the form:

A. Euler’s method – we approximate the derivative with

.
The above formula then becomes:

If we solve this for  we get:

Finally we let  .  We refer to  as the step size.

The process is iterated (repeated over and over) to get , ,  ...

The general formula is 

                   Euler’s method:	

This one isn’t in your text:

B. Modified Euler’s method – Euler’s method can be made much more accurate by averaging the slopes between two successive iterations.  The algorithm is in two parts:

	    Modified Euler’s method:	

Complete this lab on ONE spreadsheet file, BUT use a new “sheet” for each problem.  Please label the problems on each sheet.
Problem 1:  Solve the linear differential equation    by hand (you will need the analytical solution to fill in the ‘Exact’ column in the lab).  Please hand in a written version of your solution.

Problem 2: Solution by Euler’s and modified Euler’s method:

A. Open up a copy of the lab template (in you’re My Page Course Homepage File) or copy the template below into the first 9 rows into Excel or another spreadsheet of your choice. If you use a spreadsheet program that I don’t have, you’ll need to hand in a printed copy.  You may need to adjust the column widths for clarity.

Name	
	
Differential equation: y' = x2 + y;   y(0) = yo	

	
	
Analytic solution: y = 	

Value for h:	
0.1	

Value x0: = 0	
0	

Value for y0:	
0	

	

Modified Euler:	

	
	
Euler:	
u1=y0+h*(x20 + y0))	
Exact:	

	
y1=y0+h*(x20 +y0)	
y1=y0+h*1/2*((x20 + y0)+(x21 + u1))	
y = your sol'n	

step	
Xn	
Yn	
Yn	
Un	
Yn	

0	
0	
0	
0	
	
0	

B. If you are using the provided Excel file, skip to the next step.  Refer to the next to last row in the template (It has all “0”s). Extend the “step”: 1, 2, …,29,30, (so that “Steps” run from 0 to 30) and Xn’s (remember, Xn+1 = Xn + h, and this can be “programmed” using Excel commands).  Be sure that your answers in column B reflect your choice of h.

C. Use Euler’s formula, generate the entry for y1. Then extend the yn values in column C down to the last row. Be sure that your answers reflect your choices of yo and h.

D. Use the Modified Euler’s method to extend the yn and un values of column D and E down to the last row. These two rows will interact with each other as un depends on yn-1 while yn depends on yn-1 and un. Be sure that your answers reflect your choices of yo and h.

E. Similarly using the (Excel) math function EXP (for the function “e^x” which should be part of your solution), extend the ‘exact’ solution in column F down to last row. This is basically a copy, drag, and paste operation. Make sure you are evaluating the exact solution at the same Xn values.  This can also be “programmed”.

F. Compute the error between your approximations (Euler’s and Modified Euler’s) and the actual solution (If you are using the provided Excel file, there are columns for these, if not, you will need to add these two additional columns).

F. Plot all three solutions on the same graph (chart). To do this:

1. Select “chart” from the “Insert” menu. 
2. Choose a line graph. 
3. In the next window, be sure the cursor is blinking in the ‘Data Range’ box. Then select     the data in the Exact, Euler, and Modified Euler columns by dragging. (You don’t want to plot the Un data, so after you select the first column of data, put a comma in the ‘Data Range’ box before selecting the next column of data.)
4. Put in the appropriate titles. 
5. Select sheet1 for the chart location. Position it near the top and to the right of the data. 
6. Select and copy the chart to sheet2 and enlarge to better see the three solution curves.

G. Finally repeat the process using these various values of yo , h and n to see how all three solutions and their graphs respond. (Hint: This should mostly be a “copy and paste” process with some slight parameter changes).

1.  yo =1 ; h = 0.1, n= 30
2.  yo =0 ; h = 0.05 (you will have to adjust how many “steps” to n=60 in order to get to x=3).

Problem 3:  Use Euler’s method (you don’t need to use Modified Euler’s for this problem) as you did above to find approximate values for the solution to 
y’= y2 –x 
with two different initial conditions:

y(0)= 1 and y(0)=0.5

Use h=0.05 and n = 25 (so your x values run from 0 to 1.25).

Plot the two solutions on the same graph. In writing please respond to these questions: What differences between the solutions do you notice?  Is this a problem with Euler’s Method, or is something else happening here?  Does adjusting your initial conditions change anything (y(0)=0.6 or y(0)=0.9, try some others, but you don’t need to hand this part in!)?  Use MAPLE (yes, maple) to plot a direction field with the solutions corresponding to the given initial conditions (yes you need to hand this in).  How does the direction field support your observations about your numerical approximations (that is, what Euler’s method is giving you)?   

Problem 4: The equation  can be used to model the population of the U.S. where the solution y(t) is the population (in hundred millions) at time t.  The equation is based on data collected from the Bureau of Census and assumes that t=0 corresponds to the year 1900 and t=1 corresponds to the year 2000.  Use Euler’s method (with h=0.1, y(0)=0.76) to approximate the maximum U.S. population (Use a graph as before and think about the “long term” behavior of the graph).  Use your results to predict the U.S. population in the year 2050 (t=1.5).  Can you “predict” from your graph when the rate of increase of the population is slowing down?