1
如果我做的:Sympy不分段連續函數的產品和複雜的功能跨越間斷整合
from sympy import *
x, L = symbols('x L', real=True)
f = Piecewise((1, x<=0), (-1, x<1), (0, True))
g = exp(-x * 1j)
integrate(f * g, (x, 0, L))
我得到:
Piecewise((1.0*I*exp(-1.0*I*L) - 1.0*I, L <= 0), (-1.0*I*exp(-1.0*I*L) + 1.0*I, L < 1), (-1.0*I*exp(-1.0*I) + 1.0*I, True))
但是,如果我改變最後一行爲:
integrate(f*g, (x, L/2, L))
我得到:
Integral(Piecewise((exp(-1.0*I*x), x <= 0), (-exp(-1.0*I*x), x < 1), (0, True)), (x, L/2, L))
任何有識之士將不勝感激!
感謝您回覆我的問題。我會報告它。是的,這是我正在使用的解決方法。你也是對的,只有當我使用符號限制時纔會發生失敗。 – user3304293