Sympy fails to integrate the product of a piecewise continuous function and a complex function across the discontinuity

别说谁变了你拦得住时间么 提交于 2019-12-11 01:58:51

问题


If I do:

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)) 

I get:

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))

But if I change the last line to:

integrate(f*g, (x, L/2, L)) 

I get:

Integral(Piecewise((exp(-1.0*I*x), x <= 0), (-exp(-1.0*I*x), x < 1), (0, True)), (x, L/2, L))

Any insight would be appreciated!


回答1:


I guess it's not implemented yet. It probably doesn't know how to deal with the case where both limits are symbolic. You should report it.

A workaround is integrate(f*g, (x, 0, L)) - integrate(f*g, (x, 0, L/2)).



来源:https://stackoverflow.com/questions/21966759/sympy-fails-to-integrate-the-product-of-a-piecewise-continuous-function-and-a-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!