Output of sympy.fourier_transform

In summary: But based on the documentation, it seems that the difference you're seeing is due to differences in the two versions of sympy.
  • #1
Jiho
20
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
  • #2
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.
 

FAQ: Output of sympy.fourier_transform

What is the purpose of sympy.fourier_transform?

Sympy.fourier_transform is a function in the SymPy library that performs the Fourier transform on a given input. The Fourier transform is a mathematical operation that decomposes a function into its constituent frequencies, allowing for analysis and manipulation of signals in the frequency domain.

How do I use sympy.fourier_transform?

To use sympy.fourier_transform, you must first import the SymPy library and the sympy.fourier_transform function. Then, you can call the function with the desired input and parameters. For example, sympy.fourier_transform(f, x, k) would perform the Fourier transform of the function f with respect to the variable x and return the result in terms of the variable k.

What types of inputs can be used with sympy.fourier_transform?

Sympy.fourier_transform can accept a wide range of inputs, including symbolic expressions, functions, and discrete datasets. However, the input must be a finite and well-behaved function in order for the Fourier transform to be applicable.

Are there any limitations to sympy.fourier_transform?

Sympy.fourier_transform is a symbolic implementation of the Fourier transform, meaning that it is designed for analytical rather than numerical calculations. As such, it may not be as efficient as other numerical methods and may struggle with highly complex or oscillatory functions.

Can sympy.fourier_transform handle multidimensional inputs?

Yes, sympy.fourier_transform can handle multidimensional inputs, but it will perform the Fourier transform along each dimension separately. To perform a multidimensional Fourier transform, the function can be called repeatedly with different variables as the transform variable.

Similar threads

Replies
4
Views
5K
Replies
8
Views
1K
Replies
8
Views
1K
Replies
7
Views
3K
Replies
15
Views
3K
Replies
3
Views
690
Replies
17
Views
2K
Back
Top