[英]Error trying to set up laplace transform equation in python in a Juypter Notebook
My code:我的代码:
import sympy as sympy
from sympy import *
from sympy import exp
from sympy.integrals import inverse_laplace_transform
from sympy.abc import a, t, x, s, X, g, G
init_printing(use_unicode=True)
x, g, X = symbols('x g X', cls = Function)
y0 = 3
v0 = -5
eqn = Eq(s**2*X - s*y0 - v0 + 2*s*X - y0 - 3*X,laplace_transform(8*exp(-t), t, s) + laplace_transform(DiracDelta(t-1/2),t ,s))
I get the following error:我收到以下错误:
TypeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/sympy/core/cache.py in wrapper(*args, **kwargs)
92 try:
---> 93 retval = cfunc(*args, **kwargs)
94 except TypeError:
8 frames
TypeError: as_base_exp() missing 1 required positional argument: 'self'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/sympy/core/mul.py in flatten(cls, seq)
291 # e
292 # o = b
--> 293 b, e = o.as_base_exp()
294
295 # y
TypeError: as_base_exp() missing 1 required positional argument: 'self'
How would I solve this error code?我将如何解决此错误代码?
Maybe you can try to declare functions outside the large equation first?也许您可以先尝试在大方程之外声明函数?
Example:例子:
def L(f):
return sympy.laplace_transform(f, t, s, noconds=True)
f = sympy.exp(-1*t)
and then use it inside your large equation as:然后在你的大方程中使用它:
L(8*f)
Also, I can't see that you have imported laplace_transform, only inverse_laplace transform.另外,我看不到你已经导入了 laplace_transform,只有 inverse_laplace 变换。
Documentation: https://dynamics-and-control.readthedocs.io/en/latest/1_Dynamics/3_Linear_systems/Laplace%20transforms.html文档: https://dynamics-and-control.readthedocs.io/en/latest/1_Dynamics/3_Linear_systems/Laplace%20transforms.html
I hope this answer will inspire you to fix the bug.我希望这个答案能激励你修复这个错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.