Sunday, March 16, 2025

Python to solve ODE(ordinary differential equations)

References: Udemy

Python to solve ODE(ordinary differential equations)

Coding

import numpy as np from scipy.integrate import odeint import matplotlib.pyplot as plt def returns_dydt(y,t): dydt = t**3 + (2*t**2) return dydt # initial condition y0 = 4 # values of time , from 0 to 5 t = np.linspace(0,1,20) # solving ODE y = odeint(returns_dydt,y0, t) # plot results plt.plot(t,y) plt.xlabel("Time") plt.ylabel("Y") plt.show()



Results




No comments:

Post a Comment