Saturday 28 November 2015

Diffusion of the dead - The maths of zombie invasions. Part 3, Diffusive motion.


As discussed previously, we are going to model the zombie motion using the diffusion equation. In this post we introduce the gritty details. I've interpreted the mathematical symbols intuitively, so, if you stick with it, you should find yourself understanding more than you ever thought you could.

It is impossible to overstate the importance of the diffusion equation. Wherever the movement of a modelled species can be considered random and directionless, the diffusion equation will be found. This means that by understanding the diffusion equation we are able to describe a host of different systems such as heat conduction through solids, gases (e.g. smells) spreading out through a room, proteins moving round the body, molecule transportation in chemical reactions and rainwater seeping through soil, to name but a few of the great numbers of applications.

If you've never come across diffusion before, or want to know more about it's basic properties the video below is a very good primer, although feels very much like a "Look around you" episode.

The mathematical treatment of diffusion begins by defining the variables that we will need. Let the density of zombies at a point $x$ and at a time $t$ be $Z(x,t)$ then the density has to satisfy the diffusion equation,
\begin{equation}
\frac{\partial Z}{\partial t}(x,t)=D\frac{\partial^2 Z}{\partial x^2}(x,t).
\end{equation}
To some an equation can be scarier than any zombie, but fear not. I am going to break this equation down into bits so that you are able to see the reality behind the mathematics.

Notice that the equation is made up of two terms, the left-hand side and the right-hand side, which are defined to be equal. Explicitly, the left-hand side is known as the time derivative and it simply tell us how the zombie density is changing over time,
\begin{equation}
\frac{\partial Z}{\partial t}(x,t)=\text{rate of change of $Z$ over time at a point $x$}.
\end{equation}
Although the numerical value of this term is important, what is more important is if the term is positive or negative. Specifically, if $\partial Z/\partial t$ is positive then $Z$ is increasing at that point in time, and, vice-versa, if $\partial Z/\partial t$ is negative then $Z$ is decreasing. Thus, we use this term to tell us how the zombie population is changing over time.

The term on the right-hand side is known as the second spatial derivative and it is a little more complicated than the time derivative. Essentially it encapsulates the idea that the zombies move from areas of high density to areas of low density (i.e. they spread out). To aid your intuitive understanding of this term see Figure 1.
Figure 1. A typical initial zombie density graph. There are regions of high zombie activity, e.g. a graveyard, and there are regions of low zombie density, e.g. your local library.
In the figure, there are initially more zombies on the left of the space than the right. Just before the peak in density the arrow (which is the tangent to the curve known as the spatial derivative, or $\partial Z/\partial x$ at this point) is pointing upwards. This means that as $x$ increases, so does the zombie density, $Z$. At this point
\begin{equation}
\frac{\partial Z}{\partial x}=\textrm{rate of change of $Z$ as $x$ increases} > 0.
\end{equation}
Just after the peak the arrow is pointing down thus, at this point,
\begin{equation}
\frac{\partial Z}{\partial x}=\textrm{rate of change of $Z$ as $x$ increases} < 0.
\end{equation}
Thus, at the peak, the spatial derivative is decreasing, because it goes from positive to negative. This, in turn, means that the second derivative is negative at the peak, because a negative second derivative means the first derivative is decreasing. This is analogous to statements made above about the sign of the time derivative and the growth, or decay, of the zombie population.

In summary, our hand wavy argument tells us that at local maximum $\partial^2 Z/\partial x^2<0$. Using the equality of the diffusion equation, this means that at a local maximum the time derivative is negative and, thus, the density of zombies is decreasing. A similar argument shows that the population of zombies at a local minimum increases. In summary, we see that diffusion causes zombies to move from regions of high density to low density.

Finally, we mention the factor $D$, which is called the diffusion coefficient. $D$ is a positive constant that controls the rate of movement. Specifically, the larger $D$ is the faster the zombies spread out.

And with that you now understand one of the most important partial differential equations in all of mathematics. That wasn't too hard was it? Next time we discuss the solution of the diffusion equation including some simulations and Matlab code for you to try yourself.

Saturday 14 November 2015

Diffusion of the dead - The maths of zombie invasions. Part 2, Important questions you need to ask in a zombie outbreak.


We begin modelling a zombie population in the same way that a mathematician would approach the modelling of any subject. We, first, consider what questions we want to ask, as the questions will direct which techniques we use to solve the problem. Secondly, we consider what has been done before and what factors were missing in order to achieve the answers we desire. This set of blog posts will consider three questions:
  1. How long will it take for the zombies to reach us?
  2. Can we stop the infection?
  3. Can we survive?
In order to answer these questions I, Ruth Baker, Eamonn Gaffney and Philip Maini focused on the motion of the zombies as their speed and directionality would have huge effects on these three questions. Explicitly, we used a mathematical description of diffusion as a way to model the zombies motion. This was discussed in a previous post, but I recap the main points here.
  • The original zombie infection article by Robert Smith? did not include zombie, or human movement.
  • Zombies are well known for is their slow, shuffling, random motion. The end of Dawn of the Dead (shown in the YouTube clip below) gives some great footage of zombies just going about their daily business.
  • This random motion is perfectly captured through the mathematics of diffusion.


    Of course, there is plenty of evidence to suggest that zombies are attracted to human beings, as they are the predator to our prey. However, as we will see, we are going to be over run on a time scale of minutes! Thus, although mathematicians can model directed motion, and chasing, these additional components complicate matters. Further, random motion leads to some nice simple scaling formulas that can be used to quickly calculate how long you approximately have left before you meet a zombie.

    Another simplifying assumption that we make is that we can model the zombie (and human) populations as continuous quantities. Again, this is incorrect as zombies are discrete units (even if they are missing body parts). Since we are making an assumption we will create an error in our solution. But how big is this error? In particular, if the error in the assumption is smaller than the errors in our observable data set then we do not have to worry too much. The error introduced by this assumption is actually dependent on the size of the population we are considering. The more individuals you have, you more the population will act like a continuous quantity. Since there are a lot of corpses out there, we do not think this assumption is too bad.

    Note that we could model the motion of each zombie individually, however,  the computing power needed by such a simulation is much larger than the continuum description, which can be solved completely analytically. This is particularly important in the case of the zombie apocalypse, where time spent coding a simulation, may be better spent scavenging.

    These are the basic assumptions we made when modelling a zombie population. Although I have tried to justify them you may have reservations about their validity. That is the very nature of mathematical modelling; try the simplest thing, first, and compare it to data. If you reproduce the phenomena that you are interested in then you have done your job well. However, if there is a discrepancy between the data and your maths then you have to revisit your assumptions and adapt them to make them more realistic.

    Next time we contend with the equations and model the motion of the zombie as a random walker.