Showing posts with label Partial Differential Equations. Show all posts
Showing posts with label Partial Differential Equations. Show all posts

Saturday, 23 January 2016

Diffusion of the dead - The maths of zombie invasions. Part 7, Face to face with a zombie.

So far we have only considered zombie motion. It has been an incredibly simply model, but it has been able to furnish us with a wealth of information. In particular, we have been able to predict how long it will take the zombies to get to us and we have shown that the best strategy is to run away.

Unfortunately, you can only run so far. At some point you are no longer running away from the living dead, but actually running towards a different mob of zombies. So what should you do when you finally end up having to go hand to hand with a zombie?

To model human-zombie interactions, we suppose that a meeting between the
two populations can have three possible outcomes. Either
  1. the human kills the zombie;
  2. the zombie kills the human; or
  3. the zombie infects the human and so the human becomes a zombie.
These outcomes are illustrated in Figure 1.
    Allowing $H$ to stand for the human population and $Z$ to stand for the zombie population, these three rules can be written as though they were chemical reactions:
    \begin{align}
    H+Z&\stackrel{a}{\rightarrow}H \text{ (human kills zombie)}\\
    H+Z&\stackrel{b}{\rightarrow}Z \text{ (zombie kills human)}\\
    H+Z&\stackrel{c}{\rightarrow}Z+Z \text{ (human becomes zombie).}
    \end{align}
    The letters above the arrows indicate the rate at which the transformation
    happens and are always positive. If one of the rates is much larger than the
    other two, then this "reaction" would most likely happen.
    Figure 1. The possible outcomes of a human-zombie interaction. Either (a)
    humans kill zombies, (b) zombies kill humans, or (c) zombies convert humans.
    To transform these reactions into a mathematical equation, we use the "Law of Mass Action". This law states that the rate of reaction is proportional to the product of the active populations. Simply put, this means that the above reactions are more likely to occur if we increase the number of humans and/or zombies. Thus, we can produce the following equations which govern the population dynamics
    \begin{align}\frac{\partial H}{\partial t}&=D_H\frac{\partial^2 H}{\partial x^2}-\alpha HZ\\\frac{\partial Z}{\partial t}&=D_Z\frac{\partial^2 H}{\partial x^2}+\beta HZ.\end{align}
    where $b+c=\alpha$ is the net death rate of humans and $c-a=\beta$ is the net creation rate of zombies.

    If we ignore the reactions for a second, we have seen the first part of the equations before. Explicitly we are assuming that both the zombies and humans randomly diffuse throughout their domain. Now we have previously justified the zombies' diffusive motion as they are mindless monsters. However, humans are not usually known for their random movement. Here, we use the fact that if the dead should start to rise from their graves, then panic would set in and humans would start to run away and spread out randomly from location of high population density. Thus, human movement could also be described by diffusion, although their diffusion rate is likely to be much larger than the zombies'.

    If we now include the interaction formulation once again then the equations immediately highlight some important components of this problem. Firstly, because $b$, $c>0$ and $H$, $Z\geq 0$ then the human interaction term, $-\alpha HZ$, is always negative. Thus, the  human population will only ever decrease over time.

    We could add a birth term into this equation, which would allow the population to also increase in the absence of zombies but, as we have seen previously, the time scale on which we are working on is extremely short, much shorter than the 9 months it takes for humans to reproduce! Thus we ignore the births since they are not likely to alter the populations a great deal during this period.

    Interpreting the zombie equation is not so easy. The term $c-a=\beta$ may either be positive or negative. If $(c-a)>0$ then the creation rate of zombies, $c$, must be greater than the rate which we can destroy them, $a$. In this case the humans will be wiped out as our model predicts that the zombie population will grow and the human population will die out. However, there is a small hope for us. If the rate at which humans can kill zombies is greater than the rate at which zombies can infect humans then $(c-a) < 0$. In this case both populations are decreasing, thus our survival will come down to a race of which species becomes extinct first.

    Next week we will delve into the equations more and consider the spread of infection. We will then be able to derive expressions that really tell us how to survive, or at least delay, the zombie uprising.

    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.