```python
%matplotlib inline

import matplotlib
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = (12, 9)
plt.rcParams["font.size"] = 18
```

## Radioactivity part 2, decay dynamics

### Recall simple radioactive decay

\begin{align}
        N_i(t) &= \mbox{number of isotopes i adjusted for decay [atoms]}\\
        N_i(0)&= \mbox{initial condition [atoms]}\\
        \lambda &= \mbox{decay constant} [s^{-1}]\\
        \tau_{1/2} &= \mbox{half-life [s]} \\
       \frac{dN_i(t)}{dt} &=-\lambda N_i(t)\\ 
        N_i(t) &= N_i(0)e^{-\lambda t}\\
        \tau_{1/2}&=\frac{ln(2)}{\lambda}  \\
\end{align}

### And radioactive decay with production

\begin{align}
\frac{dN(t)}{dt} &= -\mbox{rate of decay} + \mbox{rate of production}\\
\implies N(t) &= N_0 e^{-\lambda t} + \int_0^t dt'Q(t')e^{-\lambda (t-t')}\\
\end{align}

If the production rate is constant $(Q(t)=Q_0)$, this simplifies:

\begin{align}
N(t) &= N_0 e^{-\lambda t} + \frac{Q_0}{\lambda}\left[1-e^{-\lambda t}\right]\\
\end{align}



The average (or mean) life of a radionuclide is




```python
import math
def n_decay(t, n_initial=100, lam=0.4):
    """This function describes the decay of an isotope"""
    return n_initial*math.exp(-lam*t)


# This code plots the decay of an isotope
import numpy as np
y = np.arange(26.0)
x = np.arange(26.0)
for t in range(0,26):
    x[t] = t
    y[t] = n_decay(t)
    
# creates a figure and axes with matplotlib
fig, ax = plt.subplots()
scatter = plt.scatter(x, y, color='blue', s=y*20, alpha=0.4)    
ax.plot(x, y, color='red')    

# adds labels to the plot
ax.set_ylabel('N_i(t)')
ax.set_xlabel('Time')
ax.set_title('N_i')

# adds tooltips
import mpld3
labels = ['{0}% remaining'.format(i) for i in y]
tooltip = mpld3.plugins.PointLabelTooltip(scatter, labels=labels)
mpld3.plugins.connect(fig, tooltip)

mpld3.display()
```






<style>

</style>

<div id="fig_el4725145423868088167705953"></div>





```python

```

6ff5652aeafad40ac771d64e22502e40275a3946
ipynb
Jupyter Notebook
radioactivity/01-radioactivity.ipynb
katyhuff/npr247
0bc7abf483247ba1a705516393f49703d8263458
CC-BY-4.0
2018-12-17T06:07:21.000Z
2022-01-21T17:14:51.000Z
radioactivity/01-radioactivity.ipynb
katyhuff/npr247
0bc7abf483247ba1a705516393f49703d8263458
CC-BY-4.0
2018-08-29T17:27:24.000Z
2018-08-29T17:46:50.000Z
radioactivity/01-radioactivity.ipynb
katyhuff/npr247
0bc7abf483247ba1a705516393f49703d8263458
CC-BY-4.0
2018-08-25T20:00:51.000Z
2022-01-14T03:05:26.000Z
Qwen/Qwen-72B
1. YES
2. YES