\[ \small{ \begin{Bmatrix} \mathrm{amount \, of } \\ \mathrm{radioactive \, material } \\ \mathrm{at \, time \,} t + \Delta t \end{Bmatrix} = \begin{Bmatrix} \mathrm{amount \, of } \\ \mathrm{radioactive \, material } \\ \mathrm{at \,time \,} t \end{Bmatrix} - \begin{Bmatrix} \mathrm{amount \, of } \\ \mathrm{radioactive \, material } \\ \mathrm{ decayed \, in \, time \,} \Delta t \end{Bmatrix} } \]
\[ \small{ \begin{Bmatrix} \mathrm{rate \, of \, change \, of} \\ \mathrm{mass \, of \,radioactive } \\ \mathrm{material \, at \, time \,} t \end{Bmatrix} = - \begin{Bmatrix} \mathrm{rate \, of \, change \, of} \\ \mathrm{mass \, of \,decayed } \\ \mathrm{material \, at \, time \,} t \end{Bmatrix}} \]
\[ \small{ \begin{Bmatrix} \mathrm{rate \, of \, change \, of} \\ \mathrm{mass \, of \,radioactive } \\ \mathrm{material \, at \, time \,} t \end{Bmatrix} = - \begin{Bmatrix} \mathrm{rate \, of \, change \, of} \\ \mathrm{mass \, of \,decayed } \\ \mathrm{material \, at \, time \,} t \end{Bmatrix} = - \{kN\} } \]
\[ \small{\frac{dN}{dt} = - kN, \,\,\, N(0) = n_0 } \]
\[ \small{\frac{dN}{dt} = - kN, \,\,\, N(t_0) = n_0 } \]
\[ \small{ \begin{align*} \int \frac{dN}{N} &= - k \int dt \\ \ln N & = -kt + C \\ N(t) &= e^{-kt+C} = e^{-kt}e^C = A e^{-kt}\\ N(t) & = \left(n_0 e^{kt_0}\right) e^{-kt} = n_0 e^{-k(t-t_0)} \end{align*}} \]
From Listing 2.2 in book:
Our IVP is then
\[ \small{\frac{dN}{dt} = - 2N, \,\,\, N(0) = 10^5 } \]
The solution is given by
\[ \small{ N(t) = 10^5 e^{-2t} } \]
\[ \begin{align} \frac{dy}{dt} & = f(t,y), \,\, y(t_0) = y_0 \\ k_1 &= hf(t_i,y_i) \\ k_2 &= hf\left(t_i + 0.5h, y_i + 0.5k_1 \right) \\ k_3 &= hf\left(t_i + 0.5h, y_i + 0.5k_2 \right) \\ k_4 &= hf\left(t_i + h, y_i + k_3 \right) \\ y_{i+1} & = y_i + \frac{1}{6} (k_1 + 2k_2 + 2k_3 + k_4) \\ t_{i+1} &= t_i + h \end{align} \]
\[ \begin{align} \frac{dy}{dt} & = f(t,y), \,\, y(t_0) = y_0 \\ a &= hf(t_i,y_i) \\ b &= hf\left(t_i + 0.5h, y_i + 0.5a \right) \\ c &= hf\left(t_i + 0.5h, y_i + 0.5b \right) \\ d &= hf\left(t_i + h, y_i + c \right) \\ y_{i+1} & = y_i + \frac{1}{6} (a + 2b + 2c + d) \\ t_{i+1} &= t_i + h \end{align} \]
rk4plot <- function(f,x0,y0,h,n){
x <- rep(0,n)
y <- rep(0,n)
x[1] <- x0
y[1] <- y0
for(i in 1:n) {
a <- h*f(x[i], y[i])
b <- h*f(x[i] + h/2, y[i] + a/2)
c <- h*f(x[i] + h/2, y[i] + b/2)
d <- h*f(x[i] + h, y[i] + c)
y[i+1] <- y[i] + 1/6*(a + 2*b + 2*c + d)
x[i+1] <- x[i] + h
}
return(plot(x,y,type="l", col="blue"))
}
f <- function(x,y){-2*y}
rk4plot(f,0,10^5,0.1,40)
Plot matches Fig 2.3.
Recall general solution \( \small{N(t) = n_0 e^{-k(t-t_0)} } \)
Let \( t = \tau \) denote the half-life. Then
\[ \small{ \begin{align*} N(t+\tau) & = 0.5N(t) \\ n_0 e^{-k(t+\tau-t_0)} &= 0.5 n_0 e^{-k(t-t_0)} \\ n_0e^{-kt}e^{-k\tau}e^{kt_0} &= 0.5 n_0 e^{-kt}e^{kt_0 } \\ e^{-k\tau} &= 0.5 \\ -k\tau & = \ln\left(2^{-1}\right) = -\ln(2) \\ k & = \frac{\ln(2)}{\tau} \end{align*}} \]
\[ \tau \cong 5568 \, \mathrm{years} \]
\[ \small{ \begin{align*} k & = \frac{\ln(2)}{\tau} \\ & = \frac{\ln(2)}{5568} \\ & \cong 0.0001245 \end{align*}} \]
log(2)/5568
[1] 0.0001244876
log(x) for \( \ln(x) \).log10(x) for \( \log(x) \).log(x,b) for \( \log_b(x) \).\[ \small{ \frac{dN}{dt} = - kN, \,\,\, N(0) = n_0, \,\,\, t > T } \]
\[ \small{ N(t) = n_0 e^{-kt}, \,\,\, k \cong 0.0001245 } \]
\[ \small{ \begin{aligned} N(T) & = n_0 e^{-kT} \\ e^{-kT} &= \frac{N(T)}{n_0} \\ -kT &= \ln\left(\frac{N(T)}{n_0} \right) \\ T &= -\frac{1}{k} \ln\left(\frac{N(T)}{n_0} \right) \end{aligned} } \]
\[ \small{N'(t) = -k n_0 e^{-kt} = -k N(t)} \]
\[ \small{ T = -\frac{1}{k} \ln\left(\frac{N(T)}{n_0} \right) } \]
\[ \small{ \frac{N'(T)}{N'(0)} = \frac{- k N(T)}{-k N(0)} = \frac{N(T)}{n_0} } \]
\[ \small{ \frac{1.69}{13.5} = \frac{N'(T)}{N'(0)} = \frac{N(T)}{n_0} } \]
\[ \small{ T = -\frac{1}{k} \ln\left(\frac{N(T)}{n_0} \right) = -\frac{1}{k} \ln\left(\frac{1.69}{13.5}\right) \cong 16,692 } \]
-1/0.0001245*log(1.69/13.5)
[1] 16690.45