## Logisitic Population Differential Equations


In this notebook we will a simple population equation [1]


```python
## Library
import numpy as np
import math 
import matplotlib.pyplot as plt
```

## Logistic Population Equation
The logistic growth differential equation is a non-linear first order differential equation
\begin{equation}
\frac{d p}{dt}=\alpha_{Birth} p-\alpha_{Death} p^2
\end{equation}
for $a\leq t \leq b$ years, where $\alpha_{Birth}$ is the birth rate and $\alpha_{Death}$ is the death rate, with the initial condition
$$ p(a)=A. $$
As the equation is non-linear we must numverically approximate the solution.
In this simulation we set the parameters of the different equations:
*  as $\alpha_{Birth}=0.3$ and $\alpha_{Death}=0.01$, with the inital condition $p(0)=3$, over the time period $0\leq t \leq 10$.


```python
alpha_Birth=0.3
alpha_Birth=0.01
```

## Discrete Domain 
To numiercally approximate the solution we discretise the continuous domain using a step size, $h=1$, 
which gives
\begin{equation}
t_i=0+i h,
\end{equation}
for $i=0,...10$.
The figure below illustrate the discrete domain.


```python
h=1
t_end=10
t=np.arange(0,t_end+h/2,h)
fig = plt.figure(1,figsize=(5,4))
ax = fig.add_subplot(1,1,1)
ax.plot(t,0*t,'o:',color='k')
ax.set_xlabel('Time (yrs)')
plt.title('Discrete Time Domain')
plt.show()
```


```python
N=int(t_end/h) # Number of Steps
P=np.zeros(N+1) # Numerical Solution P
P[0]=3

```

We numerically approximate the differential equation using Eulers method to give the difference equation
\begin{equation}
 UPDATE EQUATION ,
\end{equation}
where $h$ is the stepsize and where $P_i$ is the numerical approximation of $p(t_i)$ at distance $t_i$, for $i=0,...,10$



```python
for i in range (1,N+1):
    P[i]=P[i-1]#+h*(alpha*P[i-1])


```

## Results
The plot bellow shows the Numerical solution $P_i$ of the Logistic Population as a function of time $t$.


```python
## Plotting Figure
fig = plt.figure(1,figsize=(4,4))

ax = fig.add_subplot(1,1,1)

ax.plot(t,P,'o:',color='red',label='Population')
ax.legend()

ax.set_xlabel('Time (yrs)')
ax.set_ylabel('Population (billions)')
#ax.legend(loc='best')
ax.set_title('Numerical Solution, P')



plt.tight_layout()
plt.subplots_adjust(top=0.85)
plt.show()

```

# References

[1] Stover, Christopher and Weisstein, Eric W. "Population Growth." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/PopulationGrowth.html


```python

```

7897610d1f8f41c8ddb9378a0ff1e19c51a4ec20
ipynb
Jupyter Notebook
.ipynb_checkpoints/06_Snow Hares and Lynxes-checkpoint.ipynb
john-s-butler-dit/CaseStudy_PredatorPrey
f7d3c2a4b27bd37db5690ea81130a47dcbb602af
MIT
.ipynb_checkpoints/06_Snow Hares and Lynxes-checkpoint.ipynb
john-s-butler-dit/CaseStudy_PredatorPrey
f7d3c2a4b27bd37db5690ea81130a47dcbb602af
MIT
.ipynb_checkpoints/06_Snow Hares and Lynxes-checkpoint.ipynb
john-s-butler-dit/CaseStudy_PredatorPrey
f7d3c2a4b27bd37db5690ea81130a47dcbb602af
MIT
Qwen/Qwen-72B
1. YES
2. YES