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.
 

Related to Output of sympy.fourier_transform

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

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

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

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

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

  • Programming and Computer Science
Replies
1
Views
4K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
2
Views
3K
  • Programming and Computer Science
Replies
1
Views
920
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
8
Views
801
Replies
26
Views
5K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
31
Views
2K
Back
Top