Using sympy's dsolve method, constant coefficient second-order linear ODE
Find a general solution for.
from sympy import *
"""
Find a general solution for ordinary differential equations
"""
x=Symbol('x') #letter'x'Is defined as the variable x
y=Symbol('y') #letter'y'Is defined as the variable y
#Find a general solution with dsolve.
dsolve(2*y(x).diff(x,2)+5*y(x).diff(x,1)+2*y(x))
Note: 5 * y (x) .diff (x, 1) in the code represents $ 5 y'(x) $. Similarly, 2 * y (x) .diff (x, 2) represents $ 2 y'' (x) $.
C1 and C2 are constants determined from the initial conditions.
Recommended Posts