23. Dynamics in One Dimension#

23.1. Overview#

In this lecture we give a quick introduction to discrete time dynamics in one dimension.

In one-dimensional models, the state of the system is described by a single variable.

Although most interesting dynamic models have two or more state variables, the one-dimensional setting is a good place to learn the foundations of dynamics and build intuition.

Let’s start with some standard imports:

import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (11, 5)  #set default figure size
import numpy as np

23.2. Some Definitions#

This section sets out the objects of interest and the kinds of properties we study.

23.2.1. Difference Equations#

A time homogeneous first order difference equation is an equation of the form

(23.1)#\[x_{t+1} = g(x_t)\]

where \(g\) is a function from some subset \(S\) of \(\mathbb R\) to itself.

Here \(S\) is called the state space and \(x\) is called the state variable.

In the definition,

  • time homogeneity means that \(g\) is the same at each time \(t\)

  • first order means dependence on only one lag (i.e., earlier states such as \(x_{t-1}\) do not enter into (23.1)).

If \(x_0 \in S\) is given, then (23.1) recursively defines the sequence

(23.2)#\[x_0, \quad x_1 = g(x_0), \quad x_2 = g(x_1) = g(g(x_0)), \quad \text{etc.}\]

This sequence is called the trajectory of \(x_0\) under \(g\).

If we define \(g^n\) to be \(n\) compositions of \(g\) with itself, then we can write the trajectory more simply as \(x_t = g^t(x_0)\) for \(t \geq 0\).

23.2.2. Example: A Linear Model#

One simple example is the linear difference equation

\[ x_{t+1} = a x_t + b, \qquad S = \mathbb R \]

where \(a, b\) are fixed constants.

In this case, given \(x_0\), the trajectory (23.2) is

(23.3)#\[x_0, \quad a x_0 + b, \quad a^2 x_0 + a b + b, \quad \text{etc.}\]

Continuing in this way, and using our knowledge of geometric series, we find that, for any \(t \geq 0\),

(23.4)#\[x_t = a^t x_0 + b \frac{1 - a^t}{1 - a}\]

This is about all we need to know about the linear model.

We have an exact expression for \(x_t\) for all \(t\) and hence a full understanding of the dynamics.

Notice in particular that \(|a| < 1\), then, by (23.4), we have

(23.5)#\[x_t \to \frac{b}{1 - a} \text{ as } t \to \infty\]

regardless of \(x_0\)

This is an example of what is called global stability, a topic we return to below.

23.2.3. Example: A Nonlinear Model#

In the linear example above, we obtained an exact analytical expression for \(x_t\) in terms of arbitrary \(t\) and \(x_0\).

This made analysis of dynamics very easy.

When models are nonlinear, however, the situation can be quite different.

For example, recall how we previously studied the law of motion for the Solow growth model, a simplified version of which is

(23.6)#\[k_{t+1} = s z k_t^{\alpha} + (1 - \delta) k_t\]

Here \(k\) is capital stock and \(s, z, \alpha, \delta\) are positive parameters with \(0 < \alpha, \delta < 1\).

If you try to iterate like we did in (23.3), you will find that the algebra gets messy quickly.

Analyzing the dynamics of this model requires a different method (see below).

23.2.4. Stability#

A steady state of the difference equation \(x_{t+1} = g(x_t)\) is a point \(x^*\) in \(S\) such that \(x^* = g(x^*)\).

In other words, \(x^*\) is a fixed point of the function \(g\) in \(S\).

For example, for the linear model \(x_{t+1} = a x_t + b\), you can use the definition to check that

  • \(x^* := b/(1-a)\) is a steady state whenever \(a \not= 1\).

  • if \(a = 1\) and \(b=0\), then every \(x \in \mathbb R\) is a steady state.

  • if \(a = 1\) and \(b \not= 0\), then the linear model has no steady state in \(\mathbb R\).

A steady state \(x^*\) of \(x_{t+1} = g(x_t)\) is called globally stable if, for all \(x_0 \in S\),

\[ x_t = g^t(x_0) \to x^* \text{ as } t \to \infty \]

For example, in the linear model \(x_{t+1} = a x_t + b\) with \(a \not= 1\), the steady state \(x^*\)

  • is globally stable if \(|a| < 1\) and

  • fails to be globally stable otherwise.

This follows directly from (23.4).

A steady state \(x^*\) of \(x_{t+1} = g(x_t)\) is called locally stable if there exists an \(\epsilon > 0\) such that

\[ | x_0 - x^* | < \epsilon \; \implies \; x_t = g^t(x_0) \to x^* \text{ as } t \to \infty \]

Obviously every globally stable steady state is also locally stable.

We will see examples below where the converse is not true.

23.3. Graphical Analysis#

As we saw above, analyzing the dynamics for nonlinear models is nontrivial.

There is no single way to tackle all nonlinear models.

However, there is one technique for one-dimensional models that provides a great deal of intuition.

This is a graphical approach based on 45 degree diagrams.

Let’s look at an example: the Solow model with dynamics given in (23.6).

We begin with some plotting code that you can ignore at first reading.

The function of the code is to produce 45 degree diagrams and time series plots.

def subplots(fs):
    "Custom subplots with axes throught the origin"
    fig, ax = plt.subplots(figsize=fs)

    # Set the axes through the origin
    for spine in ['left', 'bottom']:
        ax.spines[spine].set_position('zero')
        ax.spines[spine].set_color('green')
    for spine in ['right', 'top']:
        ax.spines[spine].set_color('none')

    return fig, ax


def plot45(g, xmin, xmax, x0, num_arrows=6, var='x'):

    xgrid = np.linspace(xmin, xmax, 200)

    fig, ax = subplots((6.5, 6))
    ax.set_xlim(xmin, xmax)
    ax.set_ylim(xmin, xmax)

    hw = (xmax - xmin) * 0.01
    hl = 2 * hw
    arrow_args = dict(fc="k", ec="k", head_width=hw,
            length_includes_head=True, lw=1,
            alpha=0.6, head_length=hl)

    ax.plot(xgrid, g(xgrid), 'b-', lw=2, alpha=0.6, label='g')
    ax.plot(xgrid, xgrid, 'k-', lw=1, alpha=0.7, label='45')

    x = x0
    xticks = [xmin]
    xtick_labels = [xmin]

    for i in range(num_arrows):
        if i == 0:
            ax.arrow(x, 0.0, 0.0, g(x), **arrow_args) # x, y, dx, dy
        else:
            ax.arrow(x, x, 0.0, g(x) - x, **arrow_args)
            ax.plot((x, x), (0, x), 'k', ls='dotted')

        ax.arrow(x, g(x), g(x) - x, 0, **arrow_args)
        xticks.append(x)
        xtick_labels.append(r'${}_{}$'.format(var, str(i)))

        x = g(x)
        xticks.append(x)
        xtick_labels.append(r'${}_{}$'.format(var, str(i+1)))
        ax.plot((x, x), (0, x), 'k', ls='dotted')

    xticks.append(xmax)
    xtick_labels.append(xmax)
    ax.set_xticks(xticks)
    ax.set_yticks(xticks)
    ax.set_xticklabels(xtick_labels)
    ax.set_yticklabels(xtick_labels)

    bbox = (0., 1.04, 1., .104)
    legend_args = {'bbox_to_anchor': bbox, 'loc': 'upper right'}

    ax.legend(ncol=2, frameon=False, **legend_args, fontsize=14)
    plt.show()

def ts_plot(g, xmin, xmax, x0, ts_length=6, var='x'):
    fig, ax = subplots((7, 5.5))
    ax.set_ylim(xmin, xmax)
    ax.set_xlabel(r'$t$', fontsize=14)
    ax.set_ylabel(r'${}_t$'.format(var), fontsize=14)
    x = np.empty(ts_length)
    x[0] = x0
    for t in range(ts_length-1):
        x[t+1] = g(x[t])
    ax.plot(range(ts_length),
            x,
            'bo-',
            alpha=0.6,
            lw=2,
            label=r'${}_t$'.format(var))
    ax.legend(loc='best', fontsize=14)
    ax.set_xticks(range(ts_length))
    plt.show()

Let’s create a 45 degree diagram for the Solow model with a fixed set of parameters

A, s, alpha, delta = 2, 0.3, 0.3, 0.4

Here’s the update function corresponding to the model.

def g(k):
    return A * s * k**alpha + (1 - delta) * k

Here is the 45 degree plot.

xmin, xmax = 0, 4  # Suitable plotting region.

plot45(g, xmin, xmax, 0, num_arrows=0)
_images/efd6921eb96f9dd9d5e7a19fddf3d358ce4154c12c14e4590fdba07b5c955026.png

The plot shows the function \(g\) and the 45 degree line.

Think of \(k_t\) as a value on the horizontal axis.

To calculate \(k_{t+1}\), we can use the graph of \(g\) to see its value on the vertical axis.

Clearly,

  • If \(g\) lies above the 45 degree line at this point, then we have \(k_{t+1} > k_t\).

  • If \(g\) lies below the 45 degree line at this point, then we have \(k_{t+1} < k_t\).

  • If \(g\) hits the 45 degree line at this point, then we have \(k_{t+1} = k_t\), so \(k_t\) is a steady state.

For the Solow model, there are two steady states when \(S = \mathbb R_+ = [0, \infty)\).

  • the origin \(k=0\)

  • the unique positive number such that \(k = s z k^{\alpha} + (1 - \delta) k\).

By using some algebra, we can show that in the second case, the steady state is

\[ k^* = \left( \frac{sz}{\delta} \right)^{1/(1-\alpha)} \]

23.3.1. Trajectories#

By the preceding discussion, in regions where \(g\) lies above the 45 degree line, we know that the trajectory is increasing.

The next figure traces out a trajectory in such a region so we can see this more clearly.

The initial condition is \(k_0 = 0.25\).

k0 = 0.25

plot45(g, xmin, xmax, k0, num_arrows=5, var='k')
_images/d0976c829e7aaec23c8ba620e013e25106ef673f495dfc8a03b8cdaf2e5fc402.png

We can plot the time series of capital corresponding to the figure above as follows:

ts_plot(g, xmin, xmax, k0, var='k')
_images/82d5fddb0515e62d73ad4ce755c7e4d31e4f92e7d7f8194363055f042584ac9b.png

Here’s a somewhat longer view:

ts_plot(g, xmin, xmax, k0, ts_length=20, var='k')
_images/631748806d78fe8a2b2d7973a34265ca31cc5237a251c668664305ce844ef66c.png

When capital stock is higher than the unique positive steady state, we see that it declines:

k0 = 2.95

plot45(g, xmin, xmax, k0, num_arrows=5, var='k')
_images/5e4304761cffdaedf8e7c31d3b87d3f5759d1a9c338f26f055391551a3a2efee.png

Here is the time series:

ts_plot(g, xmin, xmax, k0, var='k')
_images/c960d0bf8d3a2b797c987109ae8777325f8394067f82e712cf82dd3bca89f8e5.png

23.3.2. Complex Dynamics#

The Solow model is nonlinear but still generates very regular dynamics.

One model that generates irregular dynamics is the quadratic map

\[ g(x) = 4 x (1 - x), \qquad x \in [0, 1] \]

Let’s have a look at the 45 degree diagram.

xmin, xmax = 0, 1
g = lambda x: 4 * x * (1 - x)

x0 = 0.3
plot45(g, xmin, xmax, x0, num_arrows=0)
_images/2dbdf9a994483df697f5a6f310399ffae1d1a513d015d3238624d6f6419c58e3.png

Now let’s look at a typical trajectory.

plot45(g, xmin, xmax, x0, num_arrows=6)
_images/ec85c0c50fcd61866b9616e64007d7effd9af9a188cacd6938ff41fd28bcde14.png

Notice how irregular it is.

Here is the corresponding time series plot.

ts_plot(g, xmin, xmax, x0, ts_length=6)
_images/8bd0ed3d1c7a132c90254a7eb7e102e65897dba1895a80e50b1011a3f78cea7b.png

The irregularity is even clearer over a longer time horizon:

ts_plot(g, xmin, xmax, x0, ts_length=20)
_images/05f6104b431e5acf9d6dc356adf1bc3829bca77558726326aa10a5e2dd564a52.png

23.4. Exercises#

Exercise 23.1

Consider again the linear model \(x_{t+1} = a x_t + b\) with \(a \not=1\).

The unique steady state is \(b / (1 - a)\).

The steady state is globally stable if \(|a| < 1\).

Try to illustrate this graphically by looking at a range of initial conditions.

What differences do you notice in the cases \(a \in (-1, 0)\) and \(a \in (0, 1)\)?

Use \(a=0.5\) and then \(a=-0.5\) and study the trajectories

Set \(b=1\) throughout.