42  Flows on the plane

Let’s return the rabbit/fox system as an example of flow. Since there are two state quantities, \(r\) and \(f\), the state space \((r, f)\) is a plane. At each point in the state space, the flow vector gives the direction and speed of motion. Like all vectors, a flow vector has only two properties: the direction and length. The speed of motion is the length of the flow vector.

The flow itself is a vector field. This is an assignment of a vector to each point of the state space. Graphically, we depict a flow field by selecting a grid of points in the state space, finding the flow vector for each grid point, and drawing those vectors positioned at their respective grid points.

Recall from Block 5 that it is conventional to specify a vector by giving a coordinate pair for the tip of the vector with the understanding that the tail is at the origin. For the rabbit/fox system, the tip’s coordinate is \(\left({\Large\strut} g_r(r, f),\ g_f(r, f)\right)\). This notation is potentially confusing, because the letters \(r\) and \(f\) appear in so many places. Each each vector in ?fig-rf-flow2 is drawn at a particular point, say \((r=0.96, f=0.48)\). At that point, evaluate the dynamical functions: \(g_r(r=0.96, f=0.48) = 0.0207\) and \(g_r(r=0.96, f=0.48)= 0.941\).

A fixed point of the dynamics is a point in the state space where the dynamical functions both evaluate to zero. It is convenient to mark fixed points as the intersection of zero contours of the dynamical functions. Figure 42.2 shows these zero contours (red for rabbits, blue for foxes) laid on top of the flow field. Such zero contours of dynamical functions are called nullclines. (The word means “zero slope”. “Null” corresponds to zero and “cline” is the root of words like “incline” or “decline.”)

Due to the nature of fixed points, if the initial condition is at the intersection of the nullclines the state will not change. But is the fixed point stable or unstable.

As you will see, in two and higher dimensional dynamical systems, there is more than one kind of stability and more than one kind of instability. These different kinds of stability and instability have a direct correspondence to different kinds of behavior in real-world systems.

Very near the fixed point, dynamics are approximately linear. We will return to a quantitative analysis of this in Chapter Section 44. Our objective here is to show that there are several generic types of behavior and that the stability of dynamics near the fixed point has to be one of a handful of different types.

42.1 Generic behaviors

On a nullcline of a dynamical variable \(x\), the \(x\)-component of the flow must be zero. The flow will point to positive \(x\) on one side of the nullcline and negative \(x\) on the other. This is really nothing more than saying that on one side of a zero contour the function value is positive and on the other side negative. We will indicate this on the following diagrams by shading the positive side of the nullcline with the same color as the nullcline itself. Figure 42.3 shows the nullclines of a linear system on separate plots. Notice that flow in the shaded side of the \(x\) (red) nullcline the flow always has a positive component to the right. Similarly, in the shaded side of the \(y\) (blue) nullcline, the flow always has a positive component to the right.

Placing both nullclines on the same plot divides the region near the fixed point into four parts. This is generic behavior. Unless the two nullclines are the same as each other, the two nullclines split the region into four quadrants.

We can identify the quadrants by their color—white, red, blue, purple. In each quadrant, the “compass direction” of all flow vectors point to one quadrant of the compass: white to the south-west, red to the south-east, blue to the north-west, and purple to the north-east.

This particular linear flow is unstable. Notice that any initial condition in the purple quadrant will lead to a NE trajectory, away from the fixed point. Similarly, any initial condition in the white quadrant leads to a SW trajectory, again away from the fixed point. For an initial condition in the red or blue quadrants, the flow will take the trajectory into either the white or purple quandrants. The initial part of the trajectory may be towards the fixed point, but as soon as the trajectory crosses into white or purple territory, the trajectory leads away from the fixed point. So, the overall flow is unstable. This particular type of instability, where the initial path might be toward the fixed point but eventually leads away from it, is called a saddle. The flow is analogous to the movement of a marble placed on a horse saddle; it might start to roll toward the center of the saddle, but eventually it will roll off to the side.

All linear flows will lead to this quadrant structure. Another feature of the structure is that the white quadrant must always be opposite to the purple, and the red opposite to the blue. This allows us to enumerate the different possible types of stability.

A very compact summary of the dynamics shows just the four compass directions and the relative positions of the quadrants. For instance, \[\begin{array}{c|c} \color{red}{\searrow} & \color{purple}{\nearrow}\\\hline \color{gray}{\swarrow} & \color{blue}{\nwarrow} \end{array}\ ,\] corresponds to the saddle flow seen in the previous flow field.

There are, altogether, eight possible configurations:

[[See latex version below]]

Saddles are unstable, although the trajectory might approach the fixed point at first. A source is unstable; any trajectory heads away from the fixed point. A sink is stable; any trajectory heads toward the fixed point.

As for the orbits, one in a clockwise direction and the other counter-clockwise, we cannot yet say from this simple theory whether they are stable or unstable. The orbit we have already met, the rabbit-fox dynamics, has counter-clockwise trajectories that form closed loops. This is called neutral stability.

42.2 Linearization

For dynamical systems with two state variables, constructing a linear approximation to dynamics near a fixed point follows a similar procedure to that with one-state-variable systems.

  1. Locate the fixed point.
  2. Construct the first-order polynomial approximation to each of the dynamical functions at the fixed point.

For instance, the pendulum system has state variables \(\theta\) and \(v\) with dynamics \[\partial_t \theta = g_\theta(\theta, v) = v\\ \partial_t v = g_{v}(\theta, v) = - \sin(\theta) \] There is a fixed point at \(\theta = 0\), \(v=0\): this is just the situation of a pendulum hanging down that has no motion.

The dynamical function \(g_\theta(\theta, v) = v\) is already in first-order polynomial form.

The other dynamical function, \(g_v(\theta, v) = - \sin(\theta)\) is nonlinear. The first order polynomial approximation centered on the fixed point will be \[g_v(\theta, v) \approx \underbrace{\color{magenta}{g_{v}(0, 0)}}_0 + \underbrace{\color{magenta}{\partial_\theta g_v(0, 0)}}_{-\cos(0)}\ \theta + \underbrace{\color{magenta}{\partial_v g_v(0, 0)}}_0\, v\] The term \(g_v(0, 0) = 0\) because we are evaluating \(g_v()\) at a fixed point. The term \(\partial_v g_v(0, 0) = 0\) because \(g_v()\) does not depend on \(v\).

We will use \(u\) and \(w\) as the dynamical variables in the linear approximation to avoid confusion with the original, nonlinear equations. The linearized dynamics are therefore: \[\partial_t u = \ \ w\\ \partial_t w = - u\]

42.3 Exercises

Exercise 42.05

Describe the stability of each of the following flows.

Problem with Dynamics Exercises/bee-wake-bottle.Rmd

Problem with Dynamics Exercises/crow-find-sofa.Rmd

Exercise 42.11

In each of the following graphs, a flow field is annotated with a red contour and a blue contour. Your task is to determine whether a contour corresponds to a zero of the horizontal component of flow, a zero of the vertical component of flow, or neither. (Remember, if the contour is at a zero of the horizontal flow, the flow on the contour will be entirely vertical. And vice versa.)

## Warning in validate_domain(domain, free_args): Using -5 to 5 in domain for
## missing domain names.
## Warning in validate_domain(domain, free_args): Missing domain names: u, v
## Warning: Ignoring unknown parameters: inherit
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
## Warning: Removed 76 rows containing missing values (geom_segment).

  1. Plot A \(\color{blue}{\text{blue contour}}\):

    1. Zero of horizontal flow
    2. Zero of vertical flow
    3. Neither
  2. Plot A \(\color{red}{\text{red contour}}\):

    1. Zero of horizontal flow
    2. Zero of vertical flow
    3. Neither
## Warning in validate_domain(domain, free_args): Using -5 to 5 in domain for
## missing domain names.
## Warning in validate_domain(domain, free_args): Missing domain names: u, v
## Warning: Ignoring unknown parameters: inherit
## Scale for 'colour' is already present. Adding another scale for 'colour',
## which will replace the existing scale.
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
## Warning: Removed 76 rows containing missing values (geom_segment).

  1. Plot B \(\color{blue}{\text{blue contour}}\):

    1. Zero of horizontal flow
    2. Zero of vertical flow
    3. Neither
  2. Plot B \(\color{red}{\text{red contour}}\):

    1. Zero of horizontal flow
    2. Zero of vertical flow
    3. Neither

Exercise 42.13

The rabbit-fox system is nonlinear: \[\partial_t r = \alpha r - \beta r f\\ \partial_t f = - \delta f + \gamma rf\]

  1. Write down, in English, the names of the Greek letters in the above formula.

  2. Using algebra, find the fixed point \((r^\star, f^\star)\) of the rabbit-fox system.

  1. Linearize the rabbit-fox system around the fixed point and write down the linearized dynamics in this form:

\[\partial_t r = A [r - r^\star] + B [f - f^\star]\\ \partial_t f = C [r - r^\star] + D[f - f^\star]\] Your should give the values of \(A, B, C, D\) in terms of the Greek letters of the nonlinear system.

\[\partial_t r = \left(\alpha + \frac{\beta\gamma}{\delta}\right) [r - r^\star] + \alpha [f - f^\star]\\ \partial_t f = - \delta [r - r^\star] + \left(\delta + \frac{\alpha\beta}{\delta}\right) [f - f^\star]\]

Exercise 42.15

Figure 42.6 shows a flow field of the pendulum system and three pairs of trajectories, one pair for each of three initial conditions. Each trajectory starts at \(t=0\) and ends at \(t=6\).

A. Read the three different initial conditions from the graph.

B. The dark gray trajectories are for the original (nonlinear) pendulum system while the \(\color{magenta}{\text{magenta}}\) trajectories are for the linearized dynamics. Describe in words the differences in the trajectories for the nonlinear and the linearized dynamics.

C. The flow field corresponds to either the nonlinear (gray) or linearized (\(\color{magenta}{\text{magenta}}\)) dynamics. Which one is it?

Exercise 42.17

In this exercise, you will work with a particular function f() of two variables. Construct the function this way:

f <- rfun( ~ x + y, seed=103)

The goal of this exercise is to explore the connections between the optimization method of gradient ascent or descent and dynamical systems.

Here’s a plot of the function and its gradient field.

contour_plot(f(x, y) ~ x + y, domain(x=-4:4, y=-4:4)) %>%
  gradient_plot(f(x, y) ~ x + y) 
## Warning in makeFun.formula(f(x, y) ~ x, suppress.warnings = FALSE): Implicit
## variables without default values (dangerous!): y

## Warning in makeFun.formula(f(x, y) ~ x, suppress.warnings = FALSE): Implicit
## variables without default values (dangerous!): y
## Warning in makeFun.formula(f(x, y) ~ y, suppress.warnings = FALSE): Implicit
## variables without default values (dangerous!): x

## Warning in makeFun.formula(f(x, y) ~ y, suppress.warnings = FALSE): Implicit
## variables without default values (dangerous!): x

You can construct the \(x\) and \(y\) components of the gradient \(\partial_x f(x,y)\) and \(\partial_y f(x,y)\) of f() this way:

dx_f <- D(f(x, y) ~ x)
dy_f <- D(f(x, y) ~ y)

Use these two functions to define a dynamical system: \[ \partial_t x = \partial_x f(x,y)\\ \partial_t y = \partial_y f(x,y)\]

  1. Use integrateODE() to integrate the equations numerically from the initial condition \((x=0, y=-3)\). Plot the resulting trajectory as a layer on top of the contour plot and gradient field. Make the tdur= parameter in integrateODE() large enough to get very close to the high-point in the contour plot.

  2. Modify the differential equations so that they correspond to gradient descent rather than ascent. Using the initial condition \((x=-1, y=1)\), numerically integrate the differential equations and, as in (1), plot the trajectory as a layer on the contour-plot/gradient-field. Make the tdur= parameter large enough to get very close to a local minimum of \(f()\).

  3. From (2), change the initial condition to \((x=-1.25, y=1)\) and plot the trajectory. What’s different from the result in (2).