Sympy Fourier Transform of exponential decay

1.8k views Asked by At

Sympy correctly computes the FT of a double-sided exponential decay:

x, k, k0 = symbols('x k k0')
fourier_transform(exp(-k0 * abs(x)), x, k)  

--> 2k0 / (4pi^2k^2 + k0^2)

Expected by hand calculation and confirmed by http://www.thefouriertransform.com/pairs/decayingexponential.php

I tried to do the same thing for a single-sided exponential decay by defining a Piecewise function where the function returns 0 for x<0 and exp(-abs(k0)x) for x >=0

f = exp(-abs(k0)*x)
ssexp = Piecewise( (0,x<0), (f, x>=0))
fourier_transform(ssexp, x, k)

The output (I don't know how to insert formatted equations) just returns:

Fx[{0 for x<0, e-x|k0| for x>=0](k)

The LaTeX code for the output is $$ \mathcal{F}{x}\left[\begin{cases} 0 & \text{for}: x < 0 \e^{- x \left\lvert{k{0}}\right\rvert} & \text{for}: x \geq 0 \end{cases}\right]\left(k\right) $$

I've looked for examples of this kind of FT done within Python/Sympy but have not found anything.

The analytical FT of a Gaussian also works fine. Perhaps Piecewise isn't the right tool for this or I've made some other rookie mistake.

Suggestions appreciated.

The Old Guy in the Club

1

There are 1 answers

3
smichr On BEST ANSWER

Using the Heaviside function rather than Piecewise seems to be the way to go here:

>>> fourier_transform(f*Heaviside(x), x, k)
1/(2*I*pi*k + Abs(k0))

But in the most recent version of SymPy, the expression you gave also works for me:

>>> fourier_transform(ssexp, x, k)
1/(2*I*pi*k + Abs(k0))