# Notes on Lab #5

## Comparing Numerical Simulation Methods

For this lab we will return to building our own simple models, and
we will compare three sorts of results: (1) analytical computation (correct
value); (2) simulation in Vensim using Euler's Method; (3) simulation in Vensim
using Runge-Kutta 4. We will do this for two different models. (The lab
is a variant on Excerices 5.2.1,3 and 5.4.1,3.)

### Model 1

First, open up Vensim and use it to model
the system *dP/dt* = 0.10*P* with *P*_{0} = 100.
Have t going from 0 through 20, using Euler's method, with Δt = 2.

Then open up Excel, and use it to compute the analytical solution to the
equation for the corresponding times (0, 2, ..., 18, 20).

Returning to Vensim, use the Control Panel to create a graph of population,
and display it as a table. You'll want to use Modify/Running Down to get it
into columns, and you'll want to use scientific notation to keep Vensim from
representing millions with the letter M.
Next, use the copy-to-clipboard button in the table window
to copy the table into Excel, making sure that the rows line up properly.
Then use Excel to compute the relative error at each time, expressed as a
percentage. Then do a chart (plot, graph) in Excel of the relative error.
Repeat the Vensim part using Runge-Kutta 4 instead of Euler's method, and compute
the relative error for RK4 next to the relative error for Euler.

Finally, Create a new spreadsheet showing the same three-way comparison (
analytical, Euler, RK4) for Δt = 0.25.
### Model 2

Now repeat this procedure for new model:
*dP/dt* = 0.5(1-P/1000)*P* with *P*_{0} = 20.
Do you remember what sort of model this is? The analytical solution is
on page 167 (Exercise 3).
Comment briefly on what you see, including the difference between the
two models. If you're feeling ambitious, go back to the first model and plot the
relative error for the final condition (RK4, &Delta*t* = 0.25) on its
own scale, and comment on what you think is going on.
### Turnin

For this lab, you only have to turn in the PDF writeup with the plots and
commentary, not the model or Excel files.