Here we will consider the example given by ExampleΒ 1.1.3, but add some context so that we can use more of the features of Insightmaker. Here is the set up for the problem: A population of creatures is initially \(10\) and grows exponentially. If the population is \(20\) after three weeks, what will the population be in one year?
First we will give the standard formulation and solution using Calculus. The problem may be reformulated as the IVP
\begin{equation*}
P' = kP, P(0) = 10,
\end{equation*}
where \(P\) represents the number of creatures, the independent variable is \(t = \) time in weeks, and \(k\) is the continuous percent growth rate in units of \(\frac{1}{\text{weeks}}\text{.}\) We can then observe (by whatever technique you prefer) that the general solution is given by
Using the data point \(P(3) = 20\text{,}\) we find \(k = \frac{\ln(2)}{3}\approx 0.23\text{.}\) Thus, \(P(52) \approx 10e^{0.23\cdot 52} \approx 165,140\) creatures. However, this solution isnβt the point of this text! We are only including it to reference the result.
Two features we will use in this solution are having sliders linked and using the tabular output option. To show the output of the simulation as a table instead of the graph of a function, use the configuration button in the simulation window and choose "table" as indicated in the image to the right.
Adjusting the slider for \(k\) until we have \(P(3)\approx 20\text{,}\) we see the correct value of \(k\) is about \(0.23\text{.}\) If we adjust the step size in the slider below \(0.01\text{,}\) we can opbtain a more accurate value.
The first important settings are the Basic Simulation Settings. These include the following:
Simulation Start: This is the time value at the start of the simulation, which is the time value indicated by the initial value problem (\(t_0\) in DefinitionΒ 1.1.1).
Simulation Length: This is how long the simulation will run. If you are interested in the value of a stock at some specific time after the start time, you may use the difference between the specified time and the start time as the simulation length.
Two more important settings are the Advanced Simulation Settings. These include the following:
Simulation Time Step: Insightmaker simulations use numerical methods to approximate values of stocks as functions of time. The outputs are only approximated at discrete time values starting with the simulation start time and moving in the positive direction in increments of this step size. A smaller time step updates the approximation more frequently and is thus more accurate. However, smaller time steps take more computations and hence run slower.
Simulation Algorithm: The algorithms available for simulation with Insightmaker are Eulerβs Method and the 4th Order Runge-Kutta Method (RK4). Eulerβs Method uses the ODE to compute the slope at each point and follows a linear approximation to \(y\) for one time step, then repeats. The RK4 Method is more complicated and its description is beyond the scope of this text.
The primary differences between the two is accuracy vs. speed. Eulerβs Method is what is known as a first order method, which means error decreases linearly with the step size. In other words, if you cut the time step in half, the error is Eulerβs Method will also be (approximately) cut in half. The RK4 Method is a 4th order method, so the error is approximately proportional to the step size to the 4th power, i.e. if you cut the time step in half, the error will be (approximately) multiplied by \(1/16\text{.}\)
In this example we will explore the simulation algorithm and step size settings in the context of the exponential growth model ExampleΒ 1.2.1, but with initial value \(P(0)=1\) and \(k=1\text{.}\) This yields \(P(t) = e^t\text{,}\) so we know that \(P(1) = e\approx 2.718\text{.}\) Running the simulation using Eulerβs Method with a time step of \(1\text{,}\) we obtain the following graph:
Figure1.2.3.The solution given by Eulerβs Method with a time step of \(0.5\text{.}\) The black points are added to show the discrete slopes between the outputs.
When the time step is \(0.125\text{,}\) the error at \(t=1\) is \(|e-2.56578451|\approx 0.1525\text{.}\) Again, this is about half of the previous error.
Finally, when the time step is \(0.5\) and we instead use the 4th Order Runge-Kutta algorithm, the error at \(t=1\) is \(|e-2.71734619|\approx 0.001\text{.}\)
Example1.2.4.The Circular Functions as Solutions to a System.
Here we will explore the system of ODEs introduced in ExampleΒ 1.1.4 to show the scatter plot (phase plane) display setting and revisit the choice of simulation algorithm. The Insight used here can be found at circular function insight. Choosing the RK4 simulation algortithm with a step size of \(0.1\text{,}\) we obtain the following time series graphs for \(x\) and \(y\) as functions of \(t\text{.}\) In this we see a nice match for the exact analytic solutions \(x(t) = \cos(t)\) and \(y(t) = \sin(t)\text{.}\)
In the case of systems of differential equations we are often interested more in the way the dependent variables vary with each other as much as (or more than) how they vary individually with time. So see this we use the scatter plot configuration in the simulation windowβs configuration settings. We choose "show lines" and turn off "show points" to display the following:
Finally, to again illustrate the accuracy difference between Eulerβs Method and RK4, we show the result of the same simulation using Eulerβs Method:
In the next example we consider the time it takes for an ant to build a tunnel of length \(x\text{.}\) This scenario is presented in [12] as well as Project 1.6.3 in [3]. The approach presented here is specific to Insightmaker and is meant to help us understand how to build models of the real world; our examples so far have been more of an abstract mathematical nature.
Suppose that we have a mound of dirt of unknown size and we wish to tunnel through this mound. We will make the choice of a single stock, \(V\text{,}\) the volume of dirt removed from the mound in cubic centimeters. This will also be a good proxy for the length of the tunnel. The initial value for \(V\) should be \(V(0) = 0\text{.}\)
The main issue that makes the flow rate of \(V\) depend on \(V\) is that dirt scraped from the end of the tunnel must then be removed from the tunnel. We will assume that the velocity at which a volume \(\Delta{V}\) of dirt can be moved is inversely proportional to \(\Delta{V}\text{.}\) That is
\begin{equation*}
\text{velocity at which }\Delta{V}\text{ can be moved} = \frac{k_{\text{move}}}{\Delta{V}}
\end{equation*}
for some constant \(k_{\text{move}}\text{.}\) (Think about how plausible this is.)
We should have one flow into \(V\text{.}\) Clearly, \(k_{\text{scrape}}\) and \(k_{\text{move}}\) should be linked to this flow. Since the flow rate will depend on the length of the tunnel, we should also have a link from \(x\) to this flow.
Now we can derive the formula for the flow rate into \(V\text{.}\) Observe that for a small change in volume, \(\Delta{V}\text{,}\) the time it takes to remove that volume is given by
We would enter this into the formula for the flow as 1/(1/[k_scrape]+[x]/([k_move])). Observe that for finding the analytic solution to this ODE, we would write it as
Finally, we can add one more item so that we can graph the solution to the problem posed in the original SIMIODE scenario. That is, we wish to graph the time \(T(x)\) to tunnel \(x\) cm as a function of \(x\text{.}\) So far we have \(x\) as a function of time. To do this we create time as a stock, with initial value zero, and flow rate \(1\text{.}\) Now running the simulation in scatter plot format with the new time stock on the vertical axis and \(x\) on the horizontal gives us the desired graph. A complete Insight is given below (with several variables set arbitrarily at one).
Based on the results of the above simulation, is it better to have one ant dig the entire tunnel or have two ants start at opposite ends and meet in the middle?
The Insightmaker model construction in ExampleΒ 1.2.8 may seem to be built in a somewhat ad hoc way. In SectionΒ 1.3 and ChapterΒ 2 we will try to make model building more systematic. However, keep in mind that modeling is a creative endeavor; there isnβt an easy "build a model" algorithm.