Output of sympy.fourier_transform

Click For Summary
SUMMARY

The forum discussion centers on the behavior of the sympy.fourier_transform function in SymPy version 1.3 compared to version 1.1. The user reports that while the Fourier transform of exp(-x**2) evaluates correctly to a numeric value when substituting k=1, the transform of (s)*exp(-(x**2)/(s**2)) does not yield a numeric result, returning an unevaluated FourierTransform object instead. This discrepancy is attributed to the fact that the integral for the second transform does not have a closed-form solution, as indicated in the SymPy documentation.

PREREQUISITES
  • Understanding of Fourier transforms and their applications in mathematical analysis.
  • Familiarity with the SymPy library, specifically the fourier_transform function.
  • Basic knowledge of Python programming, particularly version 3.7.1.
  • Experience with symbolic mathematics and how to manipulate expressions in SymPy.
NEXT STEPS
  • Explore the SymPy documentation on fourier_transform to understand its limitations and behavior with different inputs.
  • Learn about integrals that do not have closed-form solutions and how to handle them in symbolic computation.
  • Investigate the differences between SymPy versions 1.1 and 1.3 to identify changes in functionality.
  • Experiment with alternative methods for evaluating Fourier transforms in SymPy, such as numerical integration techniques.
USEFUL FOR

Mathematicians, data scientists, and software developers working with symbolic mathematics in Python, particularly those utilizing the SymPy library for Fourier analysis.

Jiho
Messages
20
Reaction score
4
I run sympy.fourier_transform.
Python:
    from sympy import fourier_transform, exp,symbols
    from sympy.abc import x, k
 
    a=fourier_transform(exp(-x**2), x, k)
 
    s=symbols('s')
    Ori=(s)*exp(-(x**2)/(s**2))
    FT=fourier_transform(Ori,x,k)

    a.subs({k:1}).evalf()
    >>>9.16769605680502e-5
    FT.subs({s:1,k:1}).evalf()
    >>>FourierTransform(exp(-x**2), x, 1)
a.subs({k:1}).evalf() is number. It's ok. But problem is FT.subs({s:1,k:1}).evalf(). It is not number even I applied .evalf() . I want to get value of 'number'. What is the problem??

Now I'm using sympy version1.3, python version 3.7.1. This code was well run at sympy version 1.1.
 
Last edited:
Technology news on Phys.org
Jiho said:
I run sympy.fourier_transform.
Python:
    from sympy import fourier_transform, exp,symbols
    from sympy.abc import x, k
 
    a=fourier_transform(exp(-x**2), x, k)
 
    s=symbols('s')
    Ori=(s)*exp(-(x**2)/(s**2))
    FT=fourier_transform(Ori,x,k)

    a.subs({k:1}).evalf()
    >>>9.16769605680502e-5
    FT.subs({s:1,k:1}).evalf()
    >>>FourierTransform(exp(-x**2), x, 1)
a.subs({k:1}).evalf() is number. It's ok. But problem is FT.subs({s:1,k:1}).evalf(). It is not number even I applied .evalf() . I want to get value of 'number'. What is the problem??

Now I'm using sympy version1.3, python version 3.7.1. This code was well run at sympy version 1.1.
Did you run exactly the same code on sympy 1.1?
In your code, a is set to $$\int_{-\infty}^\infty e^{-x^2}e^{-2\pi ixk} dx$$
and sympy can calculate this integral, and then replace k with 1 to get a numeric value.

In your second transform, FT is set to $$\int_{-\infty}^\infty se^{\frac{-x^2}{s^2}}e^{-2\pi ixk}dx$$
I suspect that this integral doesn't have a nice closed-form value. Per the sympy documentation for fourier_transform():
If the transform cannot be computed in closed form, this function returns an unevaluated FourierTransform object.
That's what seems to be happening here. I don't have sympy installed, so I can't verify that your code does what you say it does.
 

Similar threads

Replies
1
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 7 ·
Replies
7
Views
4K
Replies
26
Views
6K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K