Help with Discrete Sine Transform

In summary: This aliasing can be seen as a distortion of the original signal.I hope this helps.In summary, this person is new to Discrete Fourier Transform and is practicing with the discrete Sine-transform. They are using the FFTw library and are getting a poor result. They are seeking help from someone more experienced and have attached a plot and data. They mention that the dip might be explained if the cosine transform somehow crept in. They ask if anyone knows of a different library that they could try.
  • #1
kaniello
21
0
Hi,
I am a neophyte in Discrete Fourier Transform and I am procticing with discrete Sine-transform.
Specifically I want to calculate $$ \mathcal{F}_s \lbrace x \cdot e^{-x^2} \rbrace = \int\limits_{0}^{\infty } x \cdot e^{-x^2} \cdot \sin\left(x\right)\, \mathrm{d}x
= \frac{1}{2} \pi^2 \omega e^{- \frac{1}{4} \pi^2 \omega^2} $$
I am using the FFTw library and with a 64 points I get a very poor result. Can anybody please help to improve it?
This is my C++ code, plot and numerical data are attached.
Thank you very much in advance
 
Last edited:
Physics news on Phys.org
  • #2
I don't see any attachments.
Your itex "command is not working as you intend to produce laTex. I think you should use double number-signs, before and after. I think this is what you want.
$$ \mathcal{F}_s \lbrace x \cdot e^{-x^2} \rbrace = \int\limits_{0}^{\infty } x \cdot e^{-x^2} \cdot \sin\left(x\right)\, \mathrm{d}x
= \frac{1}{2} \pi^2 \omega e^{- \frac{1}{4} \pi^2 \omega^2} $$

You can always click the preview button before posting a message. There is a latex help guide available. https://www.physicsforums.com/help/latexhelp/
 
  • #3
Hello Scottdave,
thank you very much for your hint, my post looks definitely better now.
I hope that you can see the attachments now
 

Attachments

  • Code.txt
    2.1 KB · Views: 619
  • DST_Compare_Analytic_vs_Theoretical.png
    DST_Compare_Analytic_vs_Theoretical.png
    4.8 KB · Views: 528
  • #4
Your original equation has a typo (sin(?)). It would be helpful to give more information about the graphs - which is which?
 
  • #5
Hi mathman,
the original equation is $$ f(x) = x \cdot e^{-x^2}$$ . Its analytical sine-transform is given by
$$ \mathcal{F}_s \lbrace f(x) \rbrace (\omega) = \int\limits_{0}^{\infty } x \cdot e^{-x^2} \cdot \sin\left(x\right)\, \mathrm{d}x
= \frac{1}{2} \pi^2 \omega e^{- \frac{1}{4} \pi^2 \omega^2}$$
I uploaded the plot again with a legend
 

Attachments

  • DST_Compare_Analytic_vs_Theoretical.png
    DST_Compare_Analytic_vs_Theoretical.png
    5.2 KB · Views: 529
  • #6
I presume the argument for the sin is ωx. I suspect that you need a finer mesh for the Fourier transform for small ω.
 
  • #7
mathman said:
I presume the argument for the sin is ωx. I suspect that you need a finer mesh for the Fourier transform for small ω.
It has been awhile since I have done these, but I was kind of wondering how the ω just popped in when it is not in the integral.
 
  • #8
Sorry for the typing error,of course the the correct argument $$\sin \left(\omega x \right)$$. The resolution is still poor even with 256 points Can anybody tell me where the deviation between 2.0 and 7.0 comes from? (please see attachments).
 

Attachments

  • DST_Compare_Analytic_vs_Theoretical_256Pts.png
    DST_Compare_Analytic_vs_Theoretical_256Pts.png
    11.5 KB · Views: 525
  • DST_Compare_Analytic_vs_Theoretical_256Pts_zoom.png
    DST_Compare_Analytic_vs_Theoretical_256Pts_zoom.png
    9.5 KB · Views: 481
  • #9
Hi kaniello,

There seems to be a bit of a mixup with factors pi.
W|A (link) reports the sine transform to be:
$$\mathscr F_s\{xe^{-x^2}\}(\omega) = \frac 1{2\sqrt 2}\omega e^{-\frac 14 \omega^2}$$
Of course we can have a different normalization constant than the one given, but not a different argument to the exponential function.

Anyway, if I do a discrete Fourier transform on the data, I don't get the dip that you're seeing between 2 and 7.
So it appears there is something wrong with that FFTW routine that you're using.
Unfortunately I'm not familiar with it.

I do notice that the dip might be explained if the cosine transform somehow crept in - that one does have a dip between 2 and 7.
And I guess it might also be caused by a filter (window function) that is applied before applying the FFT.
Have you tried using an FFT routine from a different library?
 
Last edited:
  • #10
Dear I like Serena,
thanks a lot for your reply.

Which library did you use to perform the sine transform of ## xe^{-x^2} ## ? It would be really interesting to compare the results.

I do not apply any filter to my Input data but I will try to understand from the FFTw Website if it is somehow executed automatically
 
  • #11
You're welcome.
I didn't use any library - for a quick check I just used Excel's built in Fourier transform (one of the Data Analysis Tools).
 
  • #12
Hello @kaniello . I just thought I would add some information for you, since you did state you are new to Discrete Fourier Transforms.
Are you aware of how sampling frequency affects the ability to regain the original signal? Every time varying signal is composed of various sinusoidal frequencies.
For the highest frequency in the time varying signal, you must sample at a rate at least twice of that frequency.

You may find this Wikipedia article helpful, to start. https://en.wikipedia.org/wiki/Nyquist_frequency

In real-world digital signal processing, we want to make sure that we are sampling at a high enough frequency. That is why a low pass filter is used on the signal before sampling - to filter out the higher frequencies that can lead to "aliasing".
 

Related to Help with Discrete Sine Transform

What is a Discrete Sine Transform (DST)?

A Discrete Sine Transform (DST) is a mathematical operation that transforms a discrete signal into a series of sine waves with different frequencies and amplitudes. It is commonly used in signal processing and data compression, particularly for analyzing periodic signals.

How is a Discrete Sine Transform different from a Discrete Fourier Transform?

The main difference between a Discrete Sine Transform (DST) and a Discrete Fourier Transform (DFT) is that the DST only uses sine functions while the DFT uses both sine and cosine functions. This means that the DST can only represent odd symmetrical signals, while the DFT can represent both odd and even symmetrical signals.

What are the applications of Discrete Sine Transform?

The Discrete Sine Transform (DST) has many applications in signal processing, including image and audio compression, data analysis and filtering, and solving differential equations. It is also used in scientific fields such as physics, engineering, and mathematics to analyze periodic data.

How is a Discrete Sine Transform calculated?

The Discrete Sine Transform (DST) is calculated using a series of mathematical operations, including multiplying the input signal by an appropriate set of coefficients and then summing the resulting values. This process can be done using different algorithms, such as the Fast Sine Transform (FST) or the Fast Cosine Transform (FCT).

What are the advantages of using a Discrete Sine Transform?

One advantage of using a Discrete Sine Transform (DST) is that it can efficiently compress data by reducing the number of coefficients needed to represent a signal. Additionally, the DST is often more accurate when analyzing odd symmetrical signals compared to the Discrete Fourier Transform (DFT). It is also a useful tool in various scientific fields for analyzing periodic data.

Similar threads

  • Calculus
Replies
4
Views
1K
Replies
12
Views
9K
Replies
5
Views
1K
Replies
3
Views
1K
Replies
3
Views
2K
Replies
3
Views
351
  • Calculus
Replies
3
Views
1K
Replies
2
Views
5K
  • Electrical Engineering
Replies
4
Views
353
  • Quantum Physics
Replies
4
Views
818
Back
Top