class: center, middle, inverse, title-slide .title[ # Dynamics ] .author[ ### Christopher Moore ] .date[ ### Week 04 ] --- # The genesis of the qualitative theory of differential equations > *Formerly an equation was not considered solved except when the solution was expressed by means of a finite number of known functions; but that is possible in scarcely once in a hundred times. What we can alwyas do, or rather what we may always try to do, is to solve the problem qualitatively, so to speak—that is, to find the genereal shape of the curves which the unknown function represents.* > Henri Poincaré --- Qualitative analysis of 3 continuous-time models: - Density independence - Density dependence - Positive density dependene (Allee effects) --- class: inverse, center # Density independence <iframe src="https://giphy.com/embed/2Q5tDFr07UgV2" width="480" height="360" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/science-gif-mitosis-asexual-reproduction-2Q5tDFr07UgV2">via GIPHY</a></p> --- # Density independence: a simple model `$$\frac{\mathrm{d}N}{\mathrm{d}t} = rN$$` --- # Density independence time series code ```r dens_ind <- function(t, N, parms) { with(as.list(c(N, parms)), { dN <- r*N return(list(dN)) }) } parameters <- c(r = 0.5) N0a <- 0 N0b <- 1.5 N0c <- 2.5 time.seq <- seq(from = 0, to = 30, by = 0.01) out.a <- ode(y = N0a, time = time.seq, func = dens_ind, parms = parameters) out.b <- ode(y = N0b, time = time.seq, func = dens_ind, parms = parameters) out.c <- ode(y = N0c, time = time.seq, func = dens_ind, parms = parameters) ``` --- # Density independence time series ```r par(mfrow = c(1, 3), mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = out.a[,1], y = out.a[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") plot(x = out.b[,1], y = out.b[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") plot(x = out.c[,1], y = out.c[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") ``` <!-- --> --- # Density independence population change .pull-left[ ```r Ns <- seq(from = -1, to = 11, by = 0.01) pop.change <- unlist(dens_ind(t = 1, N = Ns, parms = parameters)) par(mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = Ns, y = pop.change, las = 1, xlab = "Density (N)", ylab = "Population change (dN/dt)", type = "n") segments(x0 = -10, x1 = 20, y0 = 0, y1 = 0, lwd = 0.5) segments(y0 = -10, y1 = 20, x0 = 0, x1 = 0, lwd = 0.5) lines(x = Ns, y = pop.change, lwd = 2, col = "red") ``` ] .pull-right[ <!-- --> ] --- # Density independence per-capita change .pull-left[ ```r Ns <- seq(from = -1, to = 11, by = 0.01) pc.change <- unlist(dens_ind(t = 1, N = Ns, parms = parameters))/Ns par(mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = Ns, y = pc.change, las = 1, xlab = "Density (N)", ylab = "Population change (dN/dt)", type = "n") segments(x0 = -10, x1 = 20, y0 = 0, y1 = 0, lwd = 0.5) segments(y0 = -10, y1 = 20, x0 = 0, x1 = 0, lwd = 0.5) lines(x = Ns, y = pc.change, lwd = 2, col = "red") ``` ] .pull-right[ <!-- --> ] --- # Density independence: determinting stability Take the derivative of the density independence model with respect to `\(N\)` `$$\begin{align} \frac{\mathrm{d}N}{\mathrm{d}t} &= rN\text{, as} \\ \frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} &=\text{ what?} \end{align}$$` --- # Density independence: determinting stability **Determining stability takes two steps: (1) finding the derivative of the function with respect to `\(N\)` and (2) evaluating the derivative at each equilibrium that you calculate (or numerically solve for using a computer).** (1) Take the derivative of the density independence model `$$\frac{d\frac{dN}{dt}}{dN} = r$$` (2) Insert equilibrium values and you will find stability criteria --- # Density independence: determinting stability **Equilibrium**, `\(N^* = 0\)` The derivative: `$$\frac{d\frac{dN}{dt}}{dN} = r$$` -- Evaluating at `\(N^* = 0\)`: `$$\frac{d\frac{dN}{dt}}{dN}\Bigg|_{N^*=0} = r$$` -- The solution: `$$r$$` If `\(r<0\)`, then the point is stable; if `\(r>0\text{, then the point it unstable}\)`. --- class: inverse, center # Density dependence --- # Density dependence: logistic growth `$$\frac{\mathrm{d}N}{\mathrm{d}t} = rN\left(\frac{K-N}{K}\right)$$` --- # Density depdendence time series: code ```r dens_dep <- function(t, N, parms) { with(as.list(c(N, parms)), { dN <- r*N/K*(K - N) return(list(dN)) }) } parameters <- c(r = 0.5, K = 10) N0a <- 0 N0b <- 1.5 N0c <- 2.5 time.seq <- seq(from = 0, to = 30, by = 0.01) out.a <- ode(y = N0a, time = time.seq, func = dens_dep, parms = parameters) out.b <- ode(y = N0b, time = time.seq, func = dens_dep, parms = parameters) out.c <- ode(y = N0c, time = time.seq, func = dens_dep, parms = parameters) ``` --- # Density depdendence time series ```r par(mfrow = c(1, 3), mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = out.a[,1], y = out.a[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") plot(x = out.b[,1], y = out.b[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") plot(x = out.c[,1], y = out.c[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") ``` <!-- --> --- # Density depdendence population change .pull-left[ ```r Ns <- seq(from = -1, to = 11, by = 0.01) pop.change <- unlist(dens_dep(t = 1, N = Ns, parms = parameters)) par(mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = Ns, y = pop.change, las = 1, xlab = "Density (N)", ylab = "Population change (dN/dt)", type = "n") segments(x0 = -10, x1 = 20, y0 = 0, y1 = 0, lwd = 0.5) segments(y0 = -10, y1 = 20, x0 = 0, x1 = 0, lwd = 0.5) lines(x = Ns, y = pop.change, lwd = 2, col = "red") ``` ] .pull-right[ <!-- --> ] --- # Density dependent per-capita change .pull-left[ ```r Ns <- seq(from = -1, to = 11, by = 0.01) pc.change <- unlist(dens_dep(t = 1, N = Ns, parms = parameters))/Ns par(mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = Ns, y = pc.change, las = 1, xlab = "Density (N)", ylab = "Population change (dN/dt)", type = "n") segments(x0 = -10, x1 = 20, y0 = 0, y1 = 0, lwd = 0.5) segments(y0 = -10, y1 = 20, x0 = 0, x1 = 0, lwd = 0.5) lines(x = Ns, y = pc.change, lwd = 2, col = "red") ``` ] .pull-right[ <!-- --> ] --- # Density dependence: determinting stability Take the derivative of the logistic model `$$\begin{align} \frac{\mathrm{d}N}{\mathrm{d}t} &= rN\left(\frac{K-N}{K}\right)\text{, as} \\ \frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} &=\text{ what?} \end{align}$$` --- # Density dependence: determinting stability **Determining stability takes two steps: (1) finding the derivative of the function with respect to `\(N\)` and (2) evaluating the derivative at each equilibrium that you calculate (or numerically solve for using a computer).** (1) Take the derivative of the logistic model `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r - 2\frac{r}{K}N$$` (2) Insert equilibrium values and you will find stability criteria --- # Density dependence: determinting stability **Equilibrium 1**, `\(N^* = 0\)` The derivative: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r - 2\frac{r}{K}N$$` -- Evaluating at `\(N^* = 0\)`: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r - 2\frac{r}{K}(0) = r$$` -- The solution: `$$r$$` If `\(r<0\)`, then the point is stable; if `\(r>0\text{, then the point it unstable}\)`. --- # Density dependence: determinting stability **Equilibrium 2**, `\(N^* = K\)` The derivative: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r - 2\frac{r}{K}N$$` -- Evaluating at `\(N^* = K\)`: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r - 2\frac{r}{K}(K) = r - 2r = -r$$` -- The solution: `$$-r$$` If `\(r<0\)`, then the point is stable; if `\(r>0\text{, then the point it unstable}\)`. --- # Density dependence: stability summary 1. At `\(N^* = 0\)`, if `\(r > 0\)`, the equilibrium point is stable. -- 2. At `\(N^* = K\)`, if `\(-r\)` is positive, the equilibrium point is stable. --- class: inverse, center # A new ecological model: Allee effects  (an exciting hunting sequence: [link](https://www.youtube.com/watch?v=MRS4XrKRFMA&ab_channel=JavierDMonzon) --- # A new ecological model: Allee effects **Allee effect**: positive density dependence at low density, so that small populations grow more slowly than large ones. (First described by Warder Clyde Allee.) -- Mathematically, Allee effects can be modeled `$$\frac{\mathrm{d}N}{\mathrm{d}t} = rN\left(\frac{K-N}{K}\right)\left(\frac{N - A}{A}\right)$$` -- We have a model: let's analyze and graph it! -- What are long-term behaviors; i.e., the equilibria? Take a couple of minutes, but just look at the equation and don't do any math on paper. Write down the answer and I'll come by to check. --- # Next, plot a time series `$$\frac{\mathrm{d}N}{\mathrm{d}t} = rN\left(\frac{K-N}{K}\right)\left(\frac{N - A}{A}\right)$$` Assign any `\(r\)`, `\(K\)`, and `\(N(0)\)` values, but make sure that `\(A < K\)`. --- # Allee time series: code ```r allee <- function(t, N, parms) { with(as.list(c(N, parms)), { dN <- r*N*(1 - (N/K))*((N/A)-1) return(list(dN)) }) } parameters <- c(r = 0.5, K = 10, A = 2) N0a <- 0 N0b <- 1.5 N0c <- 2.5 time.seq <- seq(from = 0, to = 30, by = 0.01) out.a <- ode(y = N0a, time = time.seq, func = allee, parms = parameters) out.b <- ode(y = N0b, time = time.seq, func = allee, parms = parameters) out.c <- ode(y = N0c, time = time.seq, func = allee, parms = parameters) ``` --- # Allee time series ```r par(mfrow = c(1, 3), mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = out.a[,1], y = out.a[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") plot(x = out.b[,1], y = out.b[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") plot(x = out.c[,1], y = out.c[,2], las = 1, lwd = 2, xlab = "Time", ylab = "Density (N)", type = "l") ``` <!-- --> --- # Allee population change .pull-left[ ```r Ns <- seq(from = -1, to = 11, by = 0.01) pop.change <- unlist(allee(t = 1, N = Ns, parms = parameters)) par(mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = Ns, y = pop.change, las = 1, xlab = "Density (N)", ylab = "Population change (dN/dt)", type = "n") segments(x0 = -10, x1 = 20, y0 = 0, y1 = 0, lwd = 0.5) segments(y0 = -10, y1 = 20, x0 = 0, x1 = 0, lwd = 0.5) lines(x = Ns, y = pop.change, lwd = 2, col = "red") ``` ] .pull-right[ <!-- --> ] --- # Allee per-capita change .pull-left[ ```r Ns <- seq(from = -1, to = 11, by = 0.01) pc.change <- unlist(allee(t = 1, N = Ns, parms = parameters))/Ns par(mar = c(4.5, 4.5, 0.1, 0.1)) plot(x = Ns, y = pc.change, las = 1, xlab = "Density (N)", ylab = "Population change (dN/dt)", type = "n") segments(x0 = -10, x1 = 20, y0 = 0, y1 = 0, lwd = 0.5) segments(y0 = -10, y1 = 20, x0 = 0, x1 = 0, lwd = 0.5) lines(x = Ns, y = pc.change, lwd = 2, col = "red") ``` ] .pull-right[ <!-- --> ] --- # Allee population change Only changing `\(A\)` (from 2 to 10) to make Allee effect stronger <!-- --> --- # Allee population change Only changing `\(A\)` (0 to 2) to make Allee effect weaker <!-- --> --- # Allee effects: determinting stability Take the derivative of the Allee model (remember the product rule) `$$\begin{align} \frac{\mathrm{d}N}{\mathrm{d}t} &= rN\left(\frac{K-N}{K}\right)\left(\frac{N - A}{A}\right)\text{, as} \\ \frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} &=\text{ what?} \end{align}$$` --- # Allee effects: determinting stability **Determining stability takes two steps: (1) finding the derivative of the function with respect to `\(N\)` and (2) evaluating the derivative at each equilibrium that you calculate (or numerically solve for using a computer).** (1) Take the derivative of the Allee model `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r\left(\frac{K-N}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{-1}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{K-N}{K}\right)\left(\frac{1}{A}\right)$$` (2) Insert equilibrium values and you will find stability criteria --- # Allee effects: determinting stability **Equilibrium 1**, `\(N^* = 0\)` The derivative: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r\left(\frac{K-N}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{-1}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{K-N}{K}\right)\left(\frac{1}{A}\right)$$` -- Evaluating at `\(N^* = 0\)`: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N}\Bigg|_{N^*=K} = r\left(\frac{K-0}{K}\right)\left(\frac{0 - A}{A}\right) + r(K)\left(\frac{-1}{K}\right)\left(\frac{K - A}{A}\right) + r(K)\left(\frac{K-0}{K}\right)\left(\frac{1}{A}\right)$$` -- The solution: `$$-r$$` If `\(<0\)`, then the point is stable; if `\(>0\text{, then the point it unstable}\)`. --- # Allee effects: determinting stability **Equilibrium 2**, `\(N^* = K\)` The derivative: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r\left(\frac{K-N}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{-1}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{K-N}{K}\right)\left(\frac{1}{A}\right)$$` -- Evaluating at `\(N^* = K\)`: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N}\Bigg|_{N^*=K} = r\left(\frac{K-K}{K}\right)\left(\frac{K - A}{A}\right) + r(K)\left(\frac{-1}{K}\right)\left(\frac{K - A}{A}\right) + r(K)\left(\frac{K-K}{K}\right)\left(\frac{1}{A}\right)$$` -- The solution: `$$r\left(\frac{K-A}{K}\right)$$` If `\(<0\)`, then the point is stable; if `\(>0\text{, then the point it unstable}\)`. --- # Allee effects: determinting stability **Equilibrium 3**, `\(N^* = A\)` The derivative: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N} = r\left(\frac{K-N}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{-1}{K}\right)\left(\frac{N - A}{A}\right) + rN\left(\frac{K-N}{K}\right)\left(\frac{1}{A}\right)$$` -- Evaluating at `\(N^* = K\)`: `$$\frac{\mathrm{d}\frac{\mathrm{d}N}{\mathrm{d}t}}{\mathrm{d}N}\Bigg|_{N^*=A} = r\left(\frac{K-A}{K}\right)\left(\frac{A - A}{A}\right) + r(A)\left(\frac{-1}{K}\right)\left(\frac{A - A}{A}\right) + r(A)\left(\frac{K-A}{K}\right)\left(\frac{1}{A}\right)$$` -- The solution: `$$-r\left(\frac{K-A}{A}\right)$$` If `\(<0\)`, then the point is stable; if `\(>0\text{, then the point it unstable}\)`. --- # Allee effects: stability summary 1. At `\(N^* = 0\)`, if `\(r > 0\)`, the equilibrium point is stable. -- 2. At `\(N^* = K\)`, if `\(-r\left(\frac{K-A}{A}\right)\)` is positive (births are greater than deaths, and the Allee threshold is less than the carrying capacity), the equilibrium point is stable. -- 3. At `\(N^* = A\)`, if `\(r\left(\frac{K-A}{K}\right)\)` is negative (births are greater than deaths, and the Allee threshold is less than the carrying capacity), the equilibrium point is unstable. Notice that it's the same as (2.), but as the opposite sign. This should make sense when thinking about it graphically, where the curve slopes must have opposite signs for adjacent equilibria. --- class: inverse, center, middle  # I hope you're here