Literature and study of ODE Stability
In this project, numerical stability of ODE's solution is discussed. An ODE solution becomes unstable when the correct initial conditions are not taken, to avoid unstability in such a case small step size in this case time step should be used when the ODE is solved using explicit numerical method for finding the solution. Other options include assuming correct initial conditions or using an implicit numerical method, to demonstrate this a program is written which uses explicit and implicit numerical methods for solving the ODE. The results obtained are also compared against the analytical solution for reference. The ODE considered for the program is:
`dy/dt = -1000xxy - exp(-t)`with an initial condition `y(0) = 0`
The ODE is solved for 0.1s totally.
From using explicit method we get:
`y_(n+1)=y_n+ dtxx(-1000xxy-exp(-t))`
And from using implicit method we get:
`y_(n+1)=(y_n-(exp(-t)xxdt))/(1+(1000*dt))`
And the analytical solution used for comparing the solutions obtained is given below:
`y=(exp(-1000xxt)xx(1 - exp(999xxt)))/999`
The above expression is obtained by using wolfram alpha.
The link to the program is attached below:
https://drive.google.com/file/d/14AfmzZiNDED76P3Zif3J_LWbSrRefx2m/view?usp=sharing
The solution attached for varrious number of steps:
For number of steps = 500 and dt=2e-4s, the graph comparing implicit, explicit and analytical method is attached below:

For number of steps = 250 and dt=4e-4s, the graph comparing implicit,explicit and analytical method is attached below:
In the above image we can see a slight deviation of explicit scheme solution from the analytical solution
For number of steps = 50 and dt=0.002041s, the graph comparing implicit,explicit and analytical method is attached below:
From the above images we can see that implicit is stable unaffected by the step size and nearly accurate to the analytical solution whereas the explicit numerical method the solution changes depending upon the time step `dt` used, giving unphysical results when values of `dt` is higher. To avoid this, the time step should be reduced which will result in a solution as shown in first image where the explicit matches the implicit and the analytical solution.
When ODE solution becomes unstable it gives unphysical solutions as a result of ever increasing error in the system, these unphysical solutions cannot give or be taken as accurate results when doing an engineering simulation.
The stability conditions can be derived for all types of problems by keeping on reducing the time step size and comparing it against the analytical solution, the correct time step size can be found using this method. But all of this can be avoided using the implicit numerical method which is unconditionally stable for all values of time step size.