为了更清楚,我想画出摆的阻尼振动的二阶微分方程的解。有关所用方程式的wiki链接:https://en.wikipedia.org/wiki/Harmonic_oscillator
from sympy.interactive import printing
printing.init_printing(use_latex=True)
import numpy as np
import scipy as sp
from sympy import*
mport sympy as syp
`from scipy.integrate import odeint
import matplotlib.pyplot as plt
t=syp.Symbol('t')
x=syp.Function('x')(t)
m=2.0
k=5.0
a=0.5
z=a/(2.0*np.sqrt(m*k))
w=np.sqrt(k/m)
eq=x.diff(t,t)+2.0*z*w*x.diff(t)+w**2.0*x
dsolve(eq,t,0,ics={eq(1.0):0,eq(2.0):5})
尽管如此,我还是遇到了以下问题,你的回答足以帮助我找到合理的解决办法。非常感谢
您没有按预期构造
ics
参数:如果不使用浮动,答案会更好(主观上)。此外,我发现将变量
x
作为函数x
而不是应用函数x(t)
更为自然,例如:相关问题 更多 >
编程相关推荐