This homework uses the following IVP:
$$\frac{dy}{dt} = -\alpha y\\$$To calculate the exact solution, the following logic was used:
Then using the initial condition y(0) = 1, we get our exact solution:
Now, we will derive the update equation using Forward Euler time discretization
Forward Euler:
where
$$f(t_n, y_n) = \frac{dy}{dt} = -\alpha y\\$$We get:
Therefore, our update equation using Forward Euler time discretization is:
Furthermore, we know that Forward Euler time discretization loses stability with growth factors greater than 1, so we can derive a stability condition as follows:
So, our stability condition is:
The python script to find the numerical solution using this method is forwardEuler.py
.
The Plot of the numerical and exact solution for various values Δt, using α = 1:
Now, we will derive the update equation using Backward Euler time discretization Backward Euler:
Using
We can then derive our Backward Euler update equation:
It should be noted that the backward euler method for this IVP is unconditionally stable, as the stability condition is
Which is always satisfied as both Δt and α are always positive.
The python script to find the numerical solution using this method is backwardEuler.py
.
The Plot of the numerical and exact solution for various values Δt, using α = 1:
Now, we will derive the update equation using Trapezoidal Method time discretization Trapezoidal Method:
Using
We can then derive our Trapezoidal Method update equation:
The python script to find the numerical solution using this method is trapezoidal.py
.
The Plot of the numerical and exact solution for various values Δt, using α = 1: