Challenge

Week 5.2 - Literature review: ODE Stability

Stability means that errors at any stage of the computation are not amplified but are attenuated as the computation progresses. The condition of a mathematical problem relates to its sensitivity to changes in its input values. We say that a computation is numerically unstable if the uncertainty of the input values is abruptly changed by the numerical method. METHODS OF APPROACH TOWARDS STABILITY ANALYSIS :- The explicit method and implicit method are numerical analysis methods used to solve a time-dependent differential equation. The explicit method calculates the system status at a future time from the currently known system status. The implicit method calculates the system status at a future time from the system statuses at present and future times. Consider the following differential equation y’= F(x,t) The explicit method expresses it as yn+1 = yn + hF(xn,tn). That is if we know the state at n we can calculate the state at n+1 Whereas the implicit method method expresses it as y

import numpy as np
import matplotlib.pyplot as plt 

def explicit(t_total,dt):
	t=np.arange(0,t_total,dt) # NumPy arange() is one of the array creation routines based on numerical ranges. It creates an instance of ndarray with evenly spaced values and returns the reference to it.
	y=np.zeros(len(t)) #Python numpy.zeros() function returns a new array of given shape and type, where the element’s value as 0.

	for i in range(0,len(t)):
		y[i]=y[i-1]+dt*(-1000*y[i-1] -np.exp(-t[i-1]));
	return[t,y]	

def implicit(t_total,dt):
	t=np.arange(0,t_total,dt)
	y=np.zeros(len(t))

	for i in range(0,len(t)):
		y[i]=(y[i-1]-np.exp(-t[i-1])*dt)/(1+1000*dt);
	return[t,y]	

t_total=0.1
dt=0.0005
	
t,y_exp=explicit(t_total,dt)
t,y_imp=implicit(t_total,dt)
plt.plot(t,y_exp)
plt.plot(t,y_imp)
plt.legend(('Explicit','Implicit'))
plt.grid(True)
titl=('Timestep:',dt)
plt.title(titl)
plt.show()
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.