在 Sympy 中使用动态符号的微分方程

Differential equation using dynamicsymbols in Sympy

在 Sympy 中,我尝试求解这样的微分方程:

from sympy import *
from sympy.physics.vector import dynamicsymbols
x = dynamicsymbols('x')
diffeq = Eq(x(t).diff(t), x(t))
dsolve(diffeq, x(t))

但是那个returns

TypeError                           Traceback (most recent call last)
<ipython-input-10-8a45d7148b24> in <module>()
      1 x = dynamicsymbols('x')
----> 2 diffeq = Eq(x(t).diff(t), x(t))
      3 dsolve(diffeq, x(t))

TypeError: 'x' object is not callable

据我了解,dynamicsymbols 创建了 t 的函数,那么如何在微分方程中使用它?

Sympy docs are a bit confusing 作为

的输出
print(x)

事实上

x(t)

但这并不意味着应该调用 x(t):

from sympy import *
from sympy.physics.vector import dynamicsymbols
x = dynamicsymbols('x')
diffeq = Eq(diff(x, Symbol('t')), x)
dsolve(diffeq, x)   # Eq(x(t), C1*exp(t))