2024 Week 7 Higer Order ODE Solvers - Jupyter Notebook
2024 Week 7 Higer Order ODE Solvers - Jupyter Notebook
What is the stability condition for the following differential equation for negative 𝛼 using Trapezoid method :
𝑥˙ = 𝛼𝑥
Trapezoid method :
∴ 𝑥𝑛+1 = 𝑥𝑛 + Δ𝑡 ( 𝛼𝑥 +2𝛼𝑥 )
𝑛 𝑛+1
Leap-Frog scheme
= 𝑡2−2𝑥2 .
Write a python code to solve the differential equation 𝑑𝑥
𝑑𝑡
Use second order Runge-Kutta (RK2) scheme, Δ𝑡 = 0.01 and 𝑥(𝑡 = 0) = 1 . What is the value of 𝑥(𝑡 = 1) ?
Round off the answer to two decimal places.
Out[2]: 0.81
𝑑𝑥 + 𝑥cos(𝑡) + 𝑡cos(𝑥) = 0 .
Write a python code to solve the differential equation 𝑑𝑡
Use RK4 scheme, Δ𝑡 = 0.01 and 𝑥(𝑡 = 0) = 1 and find the value of 𝑥(𝑡 = 1). Round of your result to two
decimal places.
Out[3]: 0.06
Write a python code to solve the differential equation = 𝑒−𝑥 + 𝑒𝑡 using Predictor-Corrector Scheme.
𝑑𝑥
𝑑𝑡
Using Δ𝑡 = 0.01 and 𝑥(𝑡 = 0) = 1 , find the value of 𝑥(𝑡 = 2) . Round off your results to 2 decimal places.
Out[4]: 7.59
What is the name of the function in scipy.integrate module that can be used to integrate ordinary differential
equations?
odeint
[𝑒𝑖2𝑥 ] = 𝛿(𝑘 − 2)
Fourier transform of 𝑒−𝑖2𝑥
𝑒−𝑖2𝑥 is:
Similarly, the Fourier transform of
1 ∞ 1
[𝑒 ] = 2𝜋 ∫−∞ 𝑒 𝑒 𝑑𝑥 = 2𝜋 ∫−∞ 𝑒−𝑖(2+𝑘)𝑥 𝑑𝑥
−𝑖2𝑥 −𝑖2𝑥 −𝑖𝑘𝑥
∞
[𝑒−𝑖2𝑥 ] = 𝛿(𝑘 + 2)
Since 𝑓(𝑥) = 2 (𝑒𝑖2𝑥 + 𝑒−𝑖2𝑥 ), the Fourier transform of 𝑓(𝑥) is the sum of the Fourier transforms of these two
1
terms:
Out[5]: 3.05
𝑥˙ = 𝑝, 𝑝˙ = −𝑥
Consider the following set of coupled differential equations
Solve these set of differential equations using the following given conditions :
x(t=0) = 1
p(t=0) = 0
dt = 0.01
What is the value of 𝑥(𝑡 = 2π) rounded off to 3 decimal places ?
In [6]: 1 dt = 0.01
2 T = 2 * np.pi
3 N = int(T / dt)
4 x = np.zeros(N + 1)
5 p = np.zeros(N + 1)
6 x[0] = 1
7 p[0] = 0
8
9 # Euler's method to solve the equations
10 for i in range(N):
11 x[i + 1] = x[i] + p[i] * dt
12 p[i + 1] = p[i] - x[i] * dt
13
14 round(x[-1], 3)
Out[6]: 1.032