Second Order Differential Equation Using Python
Vložit
- čas přidán 24. 11. 2022
- This video demonstrates how to solve a second order differential equation using python. The library used is odeint, which is available in scipy.integrate. This solve the equation numerically.
Another way of solving a second order differential equation is using Sympy. This method gives analytical solution. The advantage is that you get the form of the solution. This allows us to know the function. This is of great values in science and mathematics. The video for this is given below.
• Solving a Second Order... - Věda a technologie
I didn´t quite understand why in sode we set z=y, could you give a little more insight please?
I cant understand the line no 2. What do you mean by y,z=y ???
how can we solve the second-order heterogeneous ode? (form of y'' + y' + y = g)
Define dy/dx =z, from where we have, dz/dx-z+y-g=0. g is treated as a constant. You will have to assume a value of g, say 9, and run the code.
can we solve the differential equation using RK method of 2nd or 4th order in python?
Yes, look up for RK23 and RK45 methods in scripy.integrate.
plt.plot(x,sol[ ;,0], sir could you please tell me what does this blank space mean
watch, czcams.com/video/XO7nvpmAAnA/video.html
It reads all the rows from the first column of the sol array. The sol variable is an array. The rows are values of y and it has one column
Public listing please
What do you mean??
@@profarvind Can you share this ipynb file?
from scipy.integrate import odeint
import matplotlib.pyplot as plt
import numpy as np
def sode(y,x):
y,z=y
dydx=[z,6*y-z]
return dydx
x=np.linspace(0,1,100)
sol=odeint(sode,[5,-5],x)
plt.plot(x,sol)
Isn't this the complete code?
For some reason, this is showing no result or error message or anything.
Can you help?
I can't share the screenshot, but the program executes on my computer. It is perfectly okay.
What is the error you are getting?
Works perfectly okay on my computer. Since you are not receiving any error or plot, I suggest you add an extra code plt.show at the end. Good luck.