sympy / sympy

A computer algebra system written in pure Python
https://sympy.org/
Other
12.97k stars 4.43k forks source link

Fourier Integral doesn't evaluate f(x) = 1 / x #22979

Open galenseilis opened 2 years ago

galenseilis commented 2 years ago

SymPy does not appear to be evaluating the Fourier transform of 1/x

>>> from sympy import *
>>> x, k = var('x k')
>>> fourier_transform(1/x, x, k)
FourierTransform(1/x, x, k)

Whereas Wolfram Alpha gets an answer that is the negative of the Fourier transform expressed in terms of angular frequency according to Wikipedia.

What is the expected behavior of sympy.fourier_transform? Why doesn't it evaluate the integral?

oscargus commented 2 years ago

Probably because SymPy cannot evaluate: image

There was a massive improvement recently for the Laplace transform thanks to @hanspi42 , based on that someone can probably improve the Fourier transform in a similar way.

jksuom commented 2 years ago

Fourier integral of 1/x does not evaluate because it is divergent. Fourier transform as an integral is only defined for Integrable functions. More generally, that can be defined for tempered distributions but those are not implemented in SymPy. Besides, 1/x is not a distribution (not locally integrable at the origin). A specific limiting process is needed to find a meaningful Fourier transform. It looks like the best way to implement that in SymPy would be to add a table of transforms for special cases.

galenseilis commented 2 years ago

Fourier integral of 1/x does not evaluate because it is divergent. Fourier transform as an integral is only defined for Integrable functions. More generally, that can be defined for tempered distributions but those are not implemented in SymPy. Besides, 1/x is not a distribution (not locally integrable at the origin). A specific limiting process is needed to find a meaningful Fourier transform. It looks like the best way to implement that in SymPy would be to add a table of transforms for special cases.

I don't know if there is a relationship between tempered distributions and Cauchy principal values, but I could see the latter being useful for certain Fourier transforms as well.