Dynamic Systems
A dynamic systems changes over time, a function relates to time.
Exponential growth
A simple example is that of exponential growth, applicable to bacterial growth in a test tube.
Assumption:
Birth rate: b b b
Death rate: d d d
Growth rate: r = b − d r=b-d r=b−d
Population size: N N N
Because both birth rate and death rate are fixed, so growth rate is also fixed.
N t + 1 = r N t N_{t+1} = rN_t Nt+1=rNt
Solution:
P r i m i t i v e f u n c t i o n : N = f ( t ) Primitive\ function:N=f(t) Primitive function:N=f(t)
D e r i v a t i o n : f ′ ( t ) = r N = r f ( t ) Derivation: f'(t) = rN=rf(t) Derivation:f′(t)=rN=rf(t)
B a c k w a r d d e r i v a t i o n : N t = f ( t ) = N 0 e r t Backward\ derivation: N_t=f(t) = N_0e^{rt} Backward derivation:Nt=f(t)=N0ert
Here we suppose N 0 = 1 N_0=1 N0=1.
t = seq(0, 10, 0.01)
r1 = 0.5
r2 = -1
n0 = 1
np = n0*exp(r1*t)
nn = n0*exp(r2*t)
plot(t,np,type = 'l',xlab = 'time', ylab = 'n', ylim = c(0, 10))
lines(t,nn,col = 'red')
legend("topleft", c("r>0","r<0"), lty=c(1, 1), col=c("red", "black"))
Conclusion:
So when r>0, n increases, otherwise, decreases.
Differential calculus in R
library(deSolve)
expGrowth = function(t, n, r){
dndt = r*n
return(list(dndt)) # the output has to be a list
}
timevec = seq(0, 20, 0.1)
r =0.1
n0 = 1
# call the ode function to solve the differential equation
out = ode(y = n0, func = expGrowth, times = timevec, parms = r)
plot(out, main = "Exponential growth")
Logistic growth
Population can not go on forever. The per capita growth rate r will decrease with population size n.
Assumption:
r = r 0 ( 1 − N K ) r=r_0(1-\frac{N}{K}) r=r0(1−KN)
N t + 1 = r N t = r 0 N t ( 1 − N t K ) N_{t+1}=rN_t=r_0N_t(1-\frac{N_t}{K}) Nt+1=rNt=r0Nt(1−KNt)
Logistic equation:
N t = K 1 + e N 0 − r t N_t=\frac{K}{1+e^{N_0-rt}} Nt=