## One Step Method
Applying the Euler formula to the first order equation
\begin{equation} 
y^{'} = (1-x)y^2-y
\end{equation}
is approximated by


\begin{equation}
\frac{w_{i+1}-w_i}{h}=(1-x_i)w_i^2-w_i
\end{equation}


Rearranging 
\begin{equation}
w_{i+1}=w_i+h((1-x_i)w_i^2-w_i)
\end{equation}



## DECLARING LIBRARIES


```python
import numpy as np
import math 

%matplotlib inline
import matplotlib.pyplot as plt # side-stepping mpl backend
import matplotlib.gridspec as gridspec # subplots
import warnings
warnings.filterwarnings("ignore")
```

## Setting up X


```python
h=0.25
x_end=1
INITIALCONDITION=1
N=int(x_end/h)
Numerical_Solution=np.zeros(N+1)
x=np.zeros(N+1)

```

## NUMERICAL SOLUTION


```python
Numerical_Solution[0]=INITIALCONDITION
x[0]=0
Analytic_Solution[0]=INITIALCONDITION
for i in range (1,N+1):
    Numerical_Solution[i]=Numerical_Solution[i-1]+h*((1-x[i-1])*Numerical_Solution[i-1]*Numerical_Solution[i-1]-Numerical_Solution[i-1])
    x[i]=x[i-1]+h
    
```

## Plotting


```python
fig = plt.figure(figsize=(8,4))
plt.plot(x,Numerical_Solution,color='red')
#ax.legend(loc='best')
plt.title('Numerical Solution')
# --- right hand plot
print('x')
print(x)
print('Numerical Solutions')
print(Numerical_Solution)

```


```python

```

98d2ca72e78e4b551571d633bd3b8fb7714a9b0a
ipynb
Jupyter Notebook
Chapter 01 - Euler Methods/Supplementary/06_Euler Method - Review Questions 1c.ipynb
jjcrofts77/Numerical-Analysis-Python
97e4b9274397f969810581ff95f4026f361a56a2
MIT
2019-09-05T21:39:12.000Z
2022-03-26T14:00:25.000Z
Chapter 01 - Euler Methods/Supplementary/06_Euler Method - Review Questions 1c.ipynb
jjcrofts77/Numerical-Analysis-Python
97e4b9274397f969810581ff95f4026f361a56a2
MIT
Chapter 01 - Euler Methods/Supplementary/06_Euler Method - Review Questions 1c.ipynb
jjcrofts77/Numerical-Analysis-Python
97e4b9274397f969810581ff95f4026f361a56a2
MIT
2021-06-17T15:34:04.000Z
2022-01-14T14:53:43.000Z
Qwen/Qwen-72B
1. YES
2. YES