Sympy 无法在不连续点上对分段连续函数和复杂函数的乘积进行积分 [英] Sympy fails to integrate the product of a piecewise continuous function and a complex function across the discontinuity

查看:12
本文介绍了Sympy 无法在不连续点上对分段连续函数和复杂函数的乘积进行积分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我这样做:

from sympy import *x, L = 符号('x L', real=True)f = 分段((1, x<=0), (-1, x<1), (0, True))g = exp(-x * 1j)积分(f * g,(x,0,L))

我明白了:

<块引用>

分段((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))

任何见解将不胜感激!

解决方案

我想它还没有实现.它可能不知道如何处理两个限制都是象征性的情况.您应该报告.

解决方法是integrate(f*g, (x, 0, L)) -integrate(f*g, (x, 0, L/2)).

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!

解决方案

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

这篇关于Sympy 无法在不连续点上对分段连续函数和复杂函数的乘积进行积分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆