# Abstract and Description

Looking at a system where a cat depends on the availability of mice for its survival and a mice depends on the scarcit of cats for its survival.

To understand this system, we came up formula below, where cats is $$c(t)$$ and mice is $$m(t)$$. Change in number of cats is represented as $$dcdt$$ and that of mice is $$dmdt$$.

$$dcdt = -.1*c + 0.15*c*m$$

$$dmdt = +0.1*m - 0.15*c*m$$

In this system, assuming there was only 10 cats and mice existing, using Heun's algorithm, we will see how this 2 snimals affect each other in the system.

# Algorithm and Discussion

The basic algorithm we will be using is Heun's Algorithm and the main objective for this project is to understand how the Heun algorithm works.

## The Heun Method

While Euler's Method is quite easy and accurate enough for simple problems it is less successful when applied to more challenging situations. Depending on the nature of the function $f(s,t)$ Euler's Method can easily under or overestimate the change. Getting satisfactory results using the Euler Method can require very small time steps, making the algorithm very slow.

There are many ways to improve the situation and we'll see a number of them in this course. Our first improvement is called "The Heun Method". The idea is to take a "fake" time step, re-evaluate the function $f(s,t)$ there, and then average the two results for the "real" timestep. This process is animated in the online slides, and I ecourage you to watch those if you can. (Check under Resources -> Slides on ACE).

Starting at $x_1$ find the slope $f(s,t)$ and extrapolate out to $x_1 + \Delta x$.

Next.. evaluate the slope at the extrapolated value of s.

Using this slope.. extrapolate *again*. Note that while the
first extrapolation underestimated the change in s, the second
overestimated. Heun's method is to use the *average* of these
two estimates:

You can see that the average is much closer to the exact solution than the original Euler Method result. In short here's how it works:

Starting at $x=x_1$, take a fake Euler step,

first evaluate f(s,t):

$$f_1 = f(s_1, x_1)$$

next jump to the next x:

$$x_2 = x_1 + \Delta x$$

estimate the new value of s:

$$s_2 = s_1 + f(s_1,x_1) \Delta x$$

Evaluate f(s,t) at the new position:

$$f_2 = f(s_2, x_2)$$

Extrapolate using the average of the 'f' values:

$$s_3 = s_1 + \frac{1}{2}(f_1 + f_2) \Delta x$$

Now $s_3$ is the Heun's Method result.

# Implementation and code

### First view of system

Looking at the first half of the system, we see thatas the cats are increasing, the mice are reducing at almost the same rate and eventualy reaches zero $$(0)$$

### Second view of system

Looking at this second graph, we see that the moment the number of cats reach zero $$(0)$$, the cats begn to decrease and it will eventually reach zero $$(0)$$

# Conclusion

From analyzing the system, we now understand how Euler algorithm works and how it shows us the relationship of cats and mice. When the cats sttart with zero, the mice increases, and if the mice starts with zero, the cats decreses at a fast rate. Again, below are the formulas for the system

$$dcdt = -.1*c + 0.15*c*m$$

$$dmdt = +0.1*m - 0.15*c*m$$