Skip to main content
Mathematics LibreTexts

4.6: Building Your Own Model Equations with Multiple Variables

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    We can take one more step to increase the complexity of the model building, by including more than one variable. Following the theme of population growth, let’s consider ecological interactions between two species. A typical scenario would be the predator-prey interaction. Let’s stick to the population-level description of the system so each species can be described by one variable (say, \(x\) and \(y\)). The first thing you should consider is each variable’s inherent dynamics, i.e., what would happen if there were no influences coming from other variables. If there is always plenty of food available for the prey, we can assume the following:

    • Prey grows if there are no predators.
    • Predators die if there are no prey.

    These assumptions can be diagrammatically illustrated in Fig. 4.6.1.

    Fig. 4.6.PNG
    Figure \(\PageIndex{1}\): Inherent dynamics of each of the prey and predator populations illustrated in a causal loop diagram.

    The type of diagrams in Figure \(\PageIndex{1}\) are called a causal loop diagram in System Dynamics [26]. Each circle, or node, in this diagram represents a state variable in the system. The self-loop arrow attached to each node represents the effect of the variables on itself (e.g., the more prey there are, the faster their growth will be, etc.). The plus/minus signs next to the arrows show whether the effect is positive or negative. We can now consider the interactions between the two variables, i.e., how one variable influences the other and vice versa. Naturally, there should be the following effects:

    • The prey’s death rate increases as the predator population increases.
    • The predators’ growth rate increases as the prey population increases.

    These interactions can be illustrated as arrows between nodes in the causal loop diagram (Fig. 4.6.2).

    Now is the time to translate the structure of the system illustrated in the diagram into mathematical equations. Each arrow in the diagram tells us whether the effect is positive or negative, but they don’t give any exact mathematical form, so we will need to create a mathematical representation for each (possibly using the aforementioned tips).

    Fig. 4.7.PNG
    Figure \(\PageIndex{2}\): Interactions between the prey and predator populations illustrated in a causal loop diagram.

    The inherent dynamics of the two variables are quite straightforward to model. Since we already know how to model growth and decay, we can just borrow those existing models as building components, like this:

    \[x_{t} =x_{t-1}+r_{x}x_{t-1}(1-\frac{x_{t-1}}{K})\label{(4.28)} \]

    \[y_{t}=y_{t-1} -d_{y}y_{t-1}\label{(4.29)} \]

    Here, I used the logistic growth model for the prey \((x)\) while using the exponential decay model for the predators \((y)\). \(r_{x}\) is the growth rate of the prey, and \(d_{y}\) is the death rate of the predators \((0 < dy < 1)\).

    To implement additional assumptions about the predator-prey interactions, we need to figure out which part of the equations should be modified. In this example it is obvious, because we already know that the interactions should change the death rate of the prey and the growth rate of the predators. These terms are not yet present in the equations above, so we can simply add a new unknown term to each equation:\[x_{t} =x_{t-1} +rx_{t-1}(1-\frac{x_{t-1}}{K})-d_{x}(y_{t-1})x_{t-1}\label{(4.30)} \]

    \[y_{t}=y_{t-1} - dy_{t-1} +r_{y}(x_{t-1})y_{t-1}\label{(4.31)} \]

    Now the problems are much better defined. We just need to come up with a mathematical form for \(d_{x}\) and \(r_{y}\).

    The death rate of the prey should be 0 if there are no predators, while it should approach 1 (= 100% mortality rate!) if there are too many predators. There are a number of mathematical formulas that behave this way. A simple example would be the following hyperbolic function

    \[d_{x}(y)=1-\frac{1}{by+1},\label{(4.32)} \]

    where \(b\) determines how quickly \(d_{x}\) increases as \(y\) increases. The growth rate of the predators should be 0 if there are no prey, while it can go up indefinitely as the prey population increases. Therefore, the simplest possible mathematical form could be

    \[r_{y}(x) =cx,\label{(4.33)} \]

    where \(c\) determines how quickly \(r_{y}\) increases as \(x\) increases. Let’s put these functions back into the equations. We obtain the following:

    \[x_{t} = x_{t-1} +rx_{t-1}(1-\frac{x_{t-1}}{K})-(1-\frac{1}{by_{t-1} +1})x_{t-1}\label{(4.34)} \]

    \[y_{t} =y_{t-1}-dy_{t-1} +cx_{t-1}y_{t-1}\label{(4.35)} \]

    Exercise \(\PageIndex{1}\)

    Test the equations above by assuming extreme values for \(x\) and \(y\), and make sure the model behaves as we intended.

    Exercise \(\PageIndex{2}\)

    Implement a simulation code for the equations above, and observe the model behavior for various parameter settings.

    Figure 4.6.3 shows a sample simulation result with \(r = b = d = c = 1\), \(K = 5\) and \(x_{0} = y_{0} = 1\). The system shows an oscillatory behavior, but as its phase space visualization (Fig. 4.6.3 right) indicates, it is not a harmonic oscillation seen in linear systems, but it is a nonlinear oscillation with distorted orbits.

    The model we have created above is actually a variation of the Lotka-Volterra model, which describes various forms of predator-prey interactions. The Lotka-Volterra model is probably one of the most famous mathematical models of nonlinear dynamical systems that involves multiple variables.

    Fig. 4.8 Left.PNGFig. 4.8 Right.PNG
    Figure \(\PageIndex{3}\): Simulation results of the predator-prey model. Left: State variables plotted over time. Blue (solid) = prey, green (dashed) = predators. Right: Phase space visualization of the same result.
    Exercise \(\PageIndex{3}\)

    Try several different parameter settings for \(r,b,d\), and \(c\), and see how the system’s behavior changes. In some cases you may find an unrealistic, invalid behavior (e.g., indefinite growth of predators). If so, revise the model to fix the problem.

    In this chapter , we reviewed some basics of mathematical modeling in difference equations. As I keep saying, the best way to learn modeling is through practice. Here are some more modeling exercises. I hope you enjoy them!

    Exercise \(\PageIndex{4}\)

    Develop a discrete-time mathematical model of two species competing for the same resource, and simulate its behavior.

    Exercise \(\PageIndex{5}\)

    Consider the dynamics of public opinions about political ideologies. For simplicity, let’s assume that there are only three options: conservative, liberal, and neutral. Conservative and liberal are equally attractive (or annoying, maybe) to people, with no fundamental asymmetry between them. The popularities of conservative and liberal ideologies can be represented by two variables, \(p_{c}\) and \(p_{t}\), respectively \((0 ≤ pc ≤ 1; 0 ≤ pl ≤ 1; 0 ≤ pc + pl ≤ 1)\). This implies that \(1−p_{c} −p_{l} = p_{n}\) represents the popularity of neutral.

    Assume that at each election poll, people will change their ideological states among the three options according to the irrelative popularities in the previous poll. For example, the rate of switching from option \(X\) to option \(Y\) can be considered proportional to \((p_{Y} − p_{X})\) if \(p_{Y} > p_{X}\), or 0 otherwise. You should consider six different cases of such switching behaviors (conservative to liberal, conservative to neutral, liberal to conservative, liberal to neutral, neutral to conservative, and neutral to liberal) and represent them in dynamical equations. Complete a discrete-time mathematical model that describes this system, and simulate its behavior. See what the possible final outcomes are after a sufficiently long time period.
    Complete a discrete-time mathematical model that describes this system, and simulate its behavior. See what the possible final outcomes are after a sufficiently long time period.

    Exercise \(\PageIndex{6}\)

    Revise the model of public opinion dynamics developed in the previous exercise so that the political parties of the two ideologies (conservative and liberal) run a political campaign to promote voters’ switching to their ideologies from their competitions, at a rate \(inversely\) proportional to their current popularity (i.e., the less popular they are, the more intense their campaign will be). Simulate the behavior of this revised model and see how such political campaigning changes the dynamics of the system.

    This page titled 4.6: Building Your Own Model Equations with Multiple Variables is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Hiroki Sayama (OpenSUNY) via source content that was edited to the style and standards of the LibreTexts platform.