例如,我們要解以下微分方程:
In [1]: from sympy import * In [2]: from sympy.abc import x, t, k In [3]: x = Function('x') In [4]: dsolve(Eq(Derivative(x(t), t) - k * x(t), 0), x(t)) Out[4]:
我們也可以設定初始條件,例如,在上例中, 時,。這樣就可以求得常數。
In [8]: dsolve(Eq(Derivative(x(t), t) - k * x(t), 0), x(t), ics = {x(0): 0.5}) Out[9]: