Equilibria, stability and the phase plane

Part 8 — Ordinary differential equations

Numerical analysis for biologists

About this lecture

In Newton for systems of equations Newton found the three steady states of the genetic toggle switch. It found the unstable middle one most often. Today we ask the questions a biologist cares about: which steady states are stable, and where does a cell starting at a given point end up?

  • The phase plane: draw the flow of a two-variable ODE instead of its time course. Nullclines and fixed points.
  • Linearisation: near a fixed point the ODE behaves like d\boldsymbol\delta/dt = J\boldsymbol\delta. The eigenvalues of the Jacobian decide stability: node, saddle, spiral, centre.
  • The separatrix of a saddle is the boundary between the basins of attraction, computed by integrating backwards in time.
  • Limit cycles: oscillations with no stable fixed point (glycolysis in yeast). One slide on bifurcation diagrams.
  • Failures: a simulation that stops at a saddle; eigenvalues with real part \approx 0.

Where we left the toggle switch

\frac{du}{dt} = \frac{\alpha}{1 + v^{2}} - u, \qquad \frac{dv}{dt} = \frac{\alpha}{1 + u^{2}} - v, \qquad \alpha = 3

state (u, v) Newton’s basin on [0,4]^2
U on (2.618, 0.382) 21 %
middle (1.213, 1.213) 57 %
V on (0.382, 2.618) 21 %
  • Newton finds where \mathbf F = \mathbf 0. It does not know which states a cell can actually sit in.
  • A real cell is never exactly at a steady state: molecules are noisy. A state matters only if small pushes die out: it must be stable.
  • Two numerical tools answer this: simulation (deSolve) and eigenvalues of J (eigen).

The phase plane

  • Each point (u, v) is a state of the cell. The ODE gives a velocity (du/dt,\ dv/dt) there: the grey arrows.
  • A trajectory follows the arrows. Squares: starts; coloured curves: solutions of the ODE.
  • Time is hidden: we see where the cell goes, not how fast.
  • Black dots: stable states. White: the middle state. Orange starts end in U on, blue in V on, the grey one (u_0 = v_0) in the middle.

Trajectories with deSolve::ode

library(deSolve)
alpha <- 3; n <- 2
toggle <- function(t, x, parms) {
  u <- x[1]; v <- x[2]
  list(c(alpha / (1 + v^n) - u,      # du/dt
         alpha / (1 + u^n) - v))     # dv/dt
}
times <- seq(0, 20, by = 0.1)
out <- ode(y = c(u = 0.5, v = 0.3), times = times, func = toggle, parms = NULL)
out[c(1, 11, 51, 201), ]
#      time        u         v
# [1,]    0 0.500000 0.3000000
# [2,]    1 1.323446 0.9689792
# [3,]    5 1.628533 0.8722946
# [4,]   20 2.587075 0.3938494
  • ode (default method lsoda, adaptive step) wants func(t, x, parms) returning a list. Plot out[, "u"] against out[, "v"] for the phase plane.

Nullclines: where one variable stands still

  • u-nullcline du/dt = 0: u = 3/(1 + v^2). On it the flow is vertical.
  • v-nullcline dv/dt = 0: v = 3/(1 + u^2). On it the flow is horizontal.
  • Fixed points (steady states) = where they cross.
  • The nullclines cut the plane into regions with a fixed sign pattern: below both, u and v grow; above both, both shrink. In the thin lenses, the flow points away from the middle state.

Stability in one variable

Logistic growth (the running OD example, r = 0.8 h^{-1}, K = 1.2): \dfrac{dN}{dt} = f(N) = rN\left(1 - \dfrac{N}{K}\right).

  • Fixed points: f(N^*) = 0, so N^* = 0 or N^* = K.
  • Push a little: N = N^* + \delta. Taylor: f(N^* + \delta) \approx \underbrace{f(N^*)}_{0} + f'(N^*)\,\delta, so \frac{d\delta}{dt} \approx f'(N^*)\,\delta \quad\Rightarrow\quad \delta(t) \approx \delta_0\, e^{f'(N^*)\,t}
  • f'(N) = r(1 - 2N/K): f'(0) = 0.8 > 0, unstable (a few cells grow); f'(1.2) = -0.8 < 0, stable (a perturbation of the plateau halves every \ln 2/0.8 = 0.87 h).

Rule: f'(N^*) < 0 stable, f'(N^*) > 0 unstable, f'(N^*) = 0 undecided.

Linearisation in two variables

Push the toggle away from a fixed point \mathbf x^*: \mathbf x = \mathbf x^* + \boldsymbol\delta. Exactly as for Newton,

\frac{d\boldsymbol\delta}{dt} = \mathbf F(\mathbf x^* + \boldsymbol\delta) \approx \underbrace{\mathbf F(\mathbf x^*)}_{\mathbf 0} + J(\mathbf x^*)\,\boldsymbol\delta \quad\Rightarrow\quad \boxed{\frac{d\boldsymbol\delta}{dt} \approx J\,\boldsymbol\delta}

At U on, (2.618, 0.382):

J = \begin{pmatrix} -1 & -1.745 \\ -0.255 & -1 \end{pmatrix}: \qquad \begin{aligned} \dot\delta_u &= -\delta_u - 1.745\,\delta_v\\ \dot\delta_v &= -0.255\,\delta_u - \delta_v \end{aligned}

  • Same J as in Newton for systems of equations; a new use. Newton solves J\boldsymbol\delta = -\mathbf F; stability asks how e^{Jt} acts on \boldsymbol\delta.
  • The two equations are coupled: \delta_v feeds \delta_u. To see growth or decay we need to uncouple them.

Eigenvalues decide

If J\mathbf v = \lambda\mathbf v, then \boldsymbol\delta(t) = e^{\lambda t}\,\mathbf v solves \dot{\boldsymbol\delta} = J\boldsymbol\delta (check: both sides equal \lambda e^{\lambda t}\mathbf v). Any start is a mix:

\boldsymbol\delta(t) = c_1\, e^{\lambda_1 t}\,\mathbf v_1 + c_2\, e^{\lambda_2 t}\,\mathbf v_2

At U on: \lambda_1 = -5/3, \mathbf v_1 = (0.934, 0.357); \lambda_2 = -1/3, \mathbf v_2 = (0.934, -0.357).

  • Both negative: every small push dies out. U on is stable.
  • The slowest decay, e^{-t/3}, sets the recovery time: a perturbation halves every 3\ln 2 = 2.1 protein lifetimes.
  • Rule: stable if all eigenvalues have \mathrm{Re}\,\lambda < 0; unstable if any has \mathrm{Re}\,\lambda > 0.

The zoo of two-variable fixed points

eigenvalues type stable?
real, both < 0 stable node yes
real, opposite signs saddle no (one direction attracts, one repels)
complex a \pm ib, a < 0 stable spiral (damped oscillation) yes
complex \pm ib, a = 0 centre undecided by linearisation

A 2 × 2 shortcut: trace and determinant

For J = \begin{pmatrix} a & b \\ c & d\end{pmatrix}: \tau = a + d, \Delta = ad - bc,

\lambda_{1,2} = \frac{\tau \pm \sqrt{\tau^2 - 4\Delta}}{2}

  • \Delta < 0: saddle.
  • \Delta > 0, \tau < 0: stable; \tau > 0: unstable.
  • \tau^2 < 4\Delta: complex, a spiral.

Toggle, U on: \tau = -2, \Delta = 0.556. Middle: \tau = -2, \Delta = -0.419 → saddle.

The toggle’s three states, classified

J <- function(x) {
  u <- x[1]; v <- x[2]
  matrix(c(-1, -alpha * n * v^(n - 1) / (1 + v^n)^2,
           -alpha * n * u^(n - 1) / (1 + u^n)^2, -1), nrow = 2, byrow = TRUE)
}
states <- rbind(U_on   = c(2.618034, 0.381966),
                middle = c(1.213412, 1.213412),
                V_on   = c(0.381966, 2.618034))
t(apply(states, 1, function(x) eigen(J(x))$values))
#              [,1]       [,2]
# U_on   -1.6666667 -0.3333333
# middle  0.1910584 -2.1910584
# V_on   -1.6666667 -0.3333333
  • U on and V on: stable nodes. Middle: a saddle, \lambda = 0.191 > 0: unstable. Two stable states = bistable.
  • eigen returns complex numbers when needed; test Re(values).

The saddle up close

eigen(J(states["middle", ]))$vectors
#            [,1]      [,2]
# [1,] -0.7071068 0.7071068
# [2,]  0.7071068 0.7071068
  • \lambda = 0.19 along (1, -1): more U, less V grows. The cell decides.
  • \lambda = -2.19 along (1, 1): changing both equally decays.
  • Trajectories come in along the diagonal and leave along (1, -1), towards U on or V on.

Eigenvalues of big networks

A <- J(states["U_on", ])
eigen(A)$values                  # sorted by |lambda| for non-symmetric A
# [1] -1.6666667 -0.3333333
power_it <- function(B, k = 100) {
  x <- c(1, 0)
  for (i in 1:k) { x <- B %*% x; x <- x / sqrt(sum(x^2)) }
  sum(x * (B %*% x))             # Rayleigh quotient
}
power_it(A)                      # largest |lambda|: says nothing about stability
# [1] -1.666667
power_it(A + 2 * diag(2)) - 2    # shift: the rightmost eigenvalue now dominates
# [1] -0.3333333
  • Stability needs the eigenvalue with the largest real part, not the largest |\lambda| that power iteration finds (Power iteration and friends).
  • 20 000 genes: do not call eigen (O(n^3)). Use a sparse iterative (Arnoldi) method for the rightmost eigenvalue: RSpectra::eigs(J, k = 1, which = "LR") (How eigen() works, and big problems).

The separatrix: the edge between two fates

The saddle’s stable direction continues as a curve, the separatrix, between the two basins. Trace it by running the ODE backwards from the saddle along \mathbf v_{\text{stable}}. Biased switch (\alpha_v = 2.9):

library(rootSolve)
au <- 3; av <- 2.9
toggle2 <- function(t, x, parms)
  list(c(au / (1 + x[2]^2) - x[1], av / (1 + x[1]^2) - x[2]))
xs <- multiroot(function(x) toggle2(0, x, NULL)[[1]], start = c(1, 1.3))$root
e  <- eigen(jacobian.full(y = xs, func = toggle2))    # FD Jacobian
e$values
# [1] -2.176727  0.176727
vs <- e$vectors[, e$values < 0]                       # stable direction
tb <- seq(0, -7, by = -0.01)                          # backwards in time
up   <- ode(y = xs + 1e-6 * vs, times = tb, func = toggle2, parms = NULL)
down <- ode(y = xs - 1e-6 * vs, times = tb, func = toggle2, parms = NULL)

Where Newton goes ≠ where the cell goes

  • Left: Newton’s basins for the biased switch (the middle state takes 57 %). Right: the fate of the ODE from each start, by simulation: U on 58 %, V on 42 %. The orange separatrix from the backward runs lies exactly on the boundary.
  • Newton’s basins are a property of the algorithm; the ODE’s basins are a property of the cell.

Try it: where does the cell go?

Failure: the simulation stops at the saddle

ode(y = c(u = 2, v = 2), times = c(0, 20, 100),
    func = toggle, parms = NULL)
#   time        u        v
# 1    0 2.000000 2.000000
# 2   20 1.213412 1.213412
# 3  100 1.213412 1.213412
  • A start on the separatrix (u = v) converges to the saddle. A start 10^{-8} off stays there for \approx 100 time units.
  • “The simulation settled” does not mean “stable”.
  • Check: eigenvalues at the end point; restart from a perturbed end point.

Oscillations: glycolysis in yeast

Yeast cells and extracts show oscillating NADH and ADP levels, with periods of about a minute (Chance et al. 1964; Hess & Boiteux 1971). Sel’kov’s model (1968), dimensionless:

\frac{du}{dt} = -u + a v + u^2 v, \qquad \frac{dv}{dt} = b - a v - u^2 v, \qquad a = 0.08,\ b = 0.6

  • v = fructose-6-phosphate (F6P), fed in at rate b. u = ADP, removed at rate 1.
  • u^2 v: the enzyme phosphofructokinase turns F6P into ADP and is activated by ADP: positive feedback.
  • One fixed point, by hand: u^* = b = 0.6, v^* = b/(a + b^2) = 1.364.

Circadian clocks, the cell cycle and the repressilator of Runge–Kutta and adaptive step size (six variables) are larger, but analysed the same way: find the fixed point, find it unstable, look for a cycle.

An unstable spiral

a <- 0.08; b <- 0.6
selkov <- function(t, x, parms) {
  u <- x[1]; v <- x[2]                   # u = ADP, v = F6P
  list(c(-u + a * v + u^2 * v,
          b - a * v - u^2 * v))
}
Jsel <- function(x) {
  u <- x[1]; v <- x[2]
  matrix(c(-1 + 2 * u * v,  a + u^2,
           -2 * u * v,     -(a + u^2)), nrow = 2, byrow = TRUE)
}
eigen(Jsel(c(b, b / (a + b^2))))$values
# [1] 0.09818182+0.6560185i 0.09818182-0.6560185i
  • \tau = 0.196 > 0, \Delta = 0.44 > 0, \tau^2 < 4\Delta: unstable spiral. Perturbations rotate and grow like e^{0.098\,t}.
  • The flow points inwards far away (substrate is bounded), outwards near the fixed point. In between, trajectories must circle: a limit cycle.

The limit cycle

  • From inside (orange, near the fixed point) the spiral grows; from outside (blue) the trajectory shrinks. Both end on the same closed orbit (black).
  • Its size and period are set by the model, not by the start: a property a biologist can measure.

Measuring the cycle

out <- ode(y = c(u = 0.61, v = 1.36), times = seq(0, 100, by = 0.01),
           func = selkov, parms = NULL)
late <- out[out[, "time"] > 60, ]                 # drop the transient
range(late[, "u"])                                # amplitude
# [1] 0.2452569 1.5175375
up <- which(diff(sign(late[, "u"] - b)) > 0)      # u crosses b upwards
diff(late[up, "time"])                            # period
# [1] 9.62 9.63 9.62
  • Period \approx 9.62 (time units of ADP turnover). Successive periods agree: the transient is over.
  • Checks: a second start gives the same range and period; halving rtol/atol changes nothing in the shown digits; the linear guess 2\pi/0.656 = 9.58 is only close because we are near the onset of oscillation.

Failure: \mathrm{Re}\,\lambda \approx 0

At \alpha = 2 the three toggle states merge at (1, 1):

alpha <- 2
F <- function(x) toggle(0, x, NULL)[[1]]
eigen(J(c(1, 1)))$values               # exact state
# [1]  0 -2
ss <- multiroot(F, start = c(3, 0.5))$root
ss                                     # J singular at root
# [1] 1.0017321 0.9982688
eigen(jacobian.full(y = ss, func = toggle))$values
# [1] -1.999998e+00 -1.964308e-06
\alpha slowest \lambda = -1 + 2/\alpha time to 1 % u(100) vs steady
3 -0.333 14 2.6180 vs 2.6180
2.1 -0.048 97 1.3717 vs 1.3702
2.01 -0.005 926 1.1686 vs 1.1051
  • \lambda \approx 0: linearisation cannot decide, and an error of 10^{-6} in the state or in J can flip the sign. Simulations relax very slowly (“critical slowing down”).

Outlook: following steady states as α changes

  • Bifurcation diagram: steady states against a parameter, solid = stable, dashed = unstable.
  • At \alpha = 2 the middle branch loses stability and two stable branches appear: bistability begins (a pitchfork).
  • Numerical continuation: step \alpha, use the previous state as Newton’s start (predictor), correct with Newton, compute eigenvalues. Detect bifurcations where \mathrm{Re}\,\lambda crosses 0.
  • Tools: AUTO, MatCont, PyDSTool, BifurcationKit.jl.

Checklist: is this steady state real?

  • Find all fixed points: nullclines for two variables, Newton from many starts for more.
  • Classify each: eigenvalues of J at the fixed point; stable iff all \mathrm{Re}\,\lambda < 0. Use \max(\mathrm{Re}\,\lambda), not values[1].
  • Is |\mathrm{Re}\,\lambda| large compared with the error in J and in the state? If not, linearisation cannot decide.
  • Do not trust “the simulation stopped”: check eigenvalues there, restart from a perturbed point, run longer than 5/|\mathrm{Re}\,\lambda|.
  • Basins: a separatrix from backward runs, checked against a grid of forward simulations.
  • Oscillations: unstable fixed point + bounded flow → look for a limit cycle; check period and amplitude are independent of the start and the tolerances.

Summary

  • Phase plane: the flow of a two-variable ODE as arrows and trajectories. Nullclines (\dot u = 0, \dot v = 0) cross at fixed points.
  • Linearisation: near \mathbf x^*, \dot{\boldsymbol\delta} \approx J(\mathbf x^*)\boldsymbol\delta, solved by e^{\lambda t}\mathbf v. Stable iff all \mathrm{Re}\,\lambda < 0. 2\times2: trace and determinant. Node, saddle, spiral, centre.
  • Toggle switch (\alpha = 3): U on and V on are stable nodes (\lambda = -5/3, -1/3); the middle state is a saddle (\lambda = 0.19, -2.19).
  • The separatrix (stable manifold of the saddle) separates the basins. Compute it by integrating backwards from the saddle. The cell’s basins are not Newton’s basins.
  • Limit cycle: an unstable spiral in a bounded flow. Sel’kov glycolysis: period 9.62.
  • Rightmost eigenvalue, not largest |\lambda|. Failures: simulations that stall at saddles; \mathrm{Re}\,\lambda \approx 0 near a bifurcation (\alpha = 2).
  • Tools: deSolve::ode / solve_ivp / ode_solvers; eigen / np.linalg.eigvals / nalgebra.

Next: Stochastic simulation: when molecule numbers are small, noise kicks the switch across the separatrix.