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

StackOverflow https://stackoverflow.com/questions/21966759

  •  15-10-2022
  •  | 
  •  

Frage

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!

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top