<a href="https://colab.research.google.com/github/john-s-butler-dit/CaseStudy_PredatorPrey/blob/master/NA01_Dodos.ipynb" target="_parent"></a>

# Numerical Assignment 1 Dodos

Name and Student ID: John Butler 999999999

Adapt the python code to model the initial value problem, which describes the Dodo population (p) in the 17th century the year (t=0) that the Dodo are exposed to man and subsequent interactions modeled by the over 10 years using a stepsize of h=0.1.
To learn more about the dodo look here [2].


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

## Dodo Population Equation before man
The Dodo population prior to being found by man is described by the non-linear, 
\begin{equation}
\frac{d p}{dt}=\alpha_{Birth} p-\alpha_{Death}p^2,
\end{equation}
where $p$ is the population at time $t$,
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. $$
TIn 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)=30$, over the time period $0\leq t \leq 10$.


```python
alpha_birth=0.3
alpha_death=0.01
```

## Discrete Time Domain
To numerically approximate the solution we discretise the continuous domain using a step size, $h=0.1$, 
which gives
\begin{equation}
t_i=0+i h,
\end{equation}
for $i=0,...100$.

The Figure below illustrate the discrete domain.


```python
h=0.1
t_end=10
t=np.arange(0,t_end+h/2,h)
fig = plt.figure(1,figsize=(14,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')
plt.show()
```


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

We numerically approximate the differential equation using Eulers method to give the difference equation
\begin{equation}
P_{i}=P_{i-1}+h \big(\alpha_{Birth} P_{i-1}-\alpha_{Death}P_{i-1}^2 \big),
\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_birth*P[i-1]-alpha_death*P[i-1]*P[i-1])


```

## Results
The plot below shows the numerical solution $P_i$ for the Dodo population as a function of time $t$.


```python
## Plotting Figure
fig = plt.figure(figsize=(14,4))
plt.plot(t,P,'o:',color='red',label='Population')
plt.legend()
plt.xlabel('Time (yrs)')
plt.ylabel('Population (thousands)')
#ax.legend(loc='best')
plt.title('Dodo Population, P')
plt.ylim(0,40)
plt.show()
```

## Dodo Population Equation after man
The Dodo population prior to being found by man is described by the non-linear, 
\begin{equation}
\frac{d p}{dt}=\alpha_{Birth} p-\alpha_{Death}p^2-p(e^{0.1t}-1),
\end{equation}
where $p$ is the population at time $t$,
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. $$
The introduction of humans to the island is simulated with the inclusion of the terms
$$-p(e^{0.1t}-1).$$

Like above the parameters are set:
*  as $\alpha_{Birth}=0.3$, and $\alpha_{Death}=0.01$ with the inital condition $p(0)=30$, over the time period $0\leq t \leq 10$.

## Problem 1
Adapt the text in blue and the code below to model the impact of humans on the Dodo population.

We numerically approximate the differential equation using Eulers method to give the difference equation
\begin{equation}
P_{i}=P_{i-1}+h \big(\alpha_{Birth} P_{i-1}-\alpha_{Death}P_{i-1}^2+ \ \color{blue}{HUMANS} \big),
\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.$

HINT: use np.exp(0.1*t[i]) for $e^{0.1t_i}$.


```python
for i in range (1,N+1):
    ### UPDATED DIFFERENCE FOR DODOS TO INCLUDE HUMANS
    P[i]=P[i-1]+h*(alpha_birth*P[i-1]-alpha_death*P[i-1]*P[i-1]-)
    ###
```


```python
## Plotting Figure
fig = plt.figure(figsize=(14,4))
plt.plot(t,P,'o:',color='red',label='Population')
plt.legend()
plt.xlabel('Time (yrs)')
plt.ylabel('Population (thousands)')
#ax.legend(loc='best')
plt.title('Dodo Population, P')
plt.show()
```

## Problem 2. 

Write a brief description of what the solution of the model tells you about the population of Dodos.


# References

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

[2] Wikipedia contributors. (2021, January 13). Dodo. In Wikipedia, The Free Encyclopedia. Retrieved 15:19, February 22, 2021, from https://en.wikipedia.org/w/index.php?title=Dodo&oldid=1000163941


```python

```

200c0f108cbca746e2c19a82170c05c498be9898
ipynb
Jupyter Notebook
NA01_Dodos.ipynb
john-s-butler-dit/CaseStudy_PredatorPrey
f7d3c2a4b27bd37db5690ea81130a47dcbb602af
MIT
NA01_Dodos.ipynb
john-s-butler-dit/CaseStudy_PredatorPrey
f7d3c2a4b27bd37db5690ea81130a47dcbb602af
MIT
NA01_Dodos.ipynb
john-s-butler-dit/CaseStudy_PredatorPrey
f7d3c2a4b27bd37db5690ea81130a47dcbb602af
MIT
Qwen/Qwen-72B
1. YES
2. YES