Topic: Independant variable for integration (to do Fourier Transform)

While both Fourier series and a Fourier transform have been created and submitted, both depended on transforming a rectangular function. As such, a single integration variable was used successfully.

However, I'm trying to get a general Fourier transform to work in Graph. In doing so, I created the waveform that I wanted to transform, entered the appropriate integral and had it graph the results. After an appropriate wait, nothing gets graphed. Using shading and zoom-to-all shows no results either. I suspect the function computed comes out to be a single value which wouldn't show on the display (being an infinitesmal point).

What I need is to be able to integrate a function over a given range of one variable and plot the results over the range of another variable. Here, the integration is over time and frequency - time for the given function (a radio signal) and frequency (for the transform's results).

In this case, I can define a waveform over time of rf(x), where x ranges from 0 to 64*pi.
the real part of the Fourier transform should be ftreal(x) = integrate(re(e^1(i*x, rf(t))), t, 0, 64*pi)
Plotting ftreal(x) over 0 to 32 doesn't show anything. I don't know what Graph is trying to do with this input as it shows no intermediate steps or will list any final value(s).

Do you have any suggestions on how to make this work? Or should I look into diving into Python to extend it to add an FFT capability?

Many thanks for a remarkably powerful tool!

Jim Horn, Columbia River Gorge, USA

Re: Independant variable for integration (to do Fourier Transform)

It has been 15 years since I last worked with Fourier transformations. But I believe it should be possible to do what you want.

Your function treal(x) = integrate(re(e^1(i*x, rf(t))), t, 0, 64*pi) has some problems. The comma after i*x is invalid and the 1 in front of the bracket seems strange.

It would help if you can attach a grf file that you believe should work.

Make sure you have Calculate with complex numbers checked in the Settings tab in the Edit|Axes dialog. Else Graph will only use real numbers.

Another user posted two files that might be of interest:

Re: Independant variable for integration (to do Fourier Transform)

Thank you, Ivan - I appreciate your help. My apologies for the errors in what I typed. It should be:

ftr(x) is integrate(re(e^-(i*x*rf(t))),t,0, w0*32)

And yes, the "Calculate with complex numbers" options is set.

I'm getting a plot of it now, but it appears to be stupendously high - it's always at the top of the graph even if Y goes up to 1E15. I'll see what I can do about that.

Best to you - and many thanks again!

Re: Independant variable for integration (to do Fourier Transform)

I tried it with rf(x)=x and I think it looks reasonable. If you have a specific case that looks wrong, I can take a look at it.

However I will mention that the integrate function is not always reliable. It doesn't use symbolic integration, but numeric integration using and advanced algorithm. In most cases it gives a very good result, but it is possible to find cases where the result looks crazy.

Re: Independant variable for integration (to do Fourier Transform)

Thank you again, Ivan. I replaced the complex exponential in the integration with sines and cosines and it is mostly working.

A question - would it be possible to pay for your time to add an FFT plugin to Graph? The FFTW C code is freely available, but I've not used Python so doing the plugin myself would take some time to catch up. If we could get that as a plugin within a week, it would really help and we're happy to cover expenses. With longer functions, the time and accuracy advantage of a Fast Fourier transform would make all the difference versus multiple numeric integrations.

If not, would you recommend someone who could do so?

Thank you again for your time and help!

Re: Independant variable for integration (to do Fourier Transform)

It sounds like fun, but I don't think I will have time to do it within a week.

But I am unsure what exactly you expect. Do you want a point series with FFT data from a function?

Re: Independant variable for integration (to do Fourier Transform)

Yes, a point series would be fine. If that can't handle a set of complex numbers (I've not used the point series yet), two functions - FFTreal and FFTimaginary or such would take care of that.

Re: Independant variable for integration (to do Fourier Transform)

I have attached a plugin that can create FFT of a function. Place the plugin file in the Plugins folder where Graph is installed. To use it you need to install Python 3.2 from … -3.2.5.msi

When you start Graph you will get a menu item called Plugins|FFT, which will calculate FFT for the selected function. It will create 4 point series, which is the same FFT in different formats. The first is the FFT in complex format, which Graph cannot plot. Therefore you also get two point series with the real and imaginary values separated. The last contains the absolute value of the complex numbers, which is usually the most useful.

The plugin will calculate the FFT for the range of the x-axis shown, so you may want to adjust the range first in the Edit|Axes dialog. It will calculate the FFT for 1024 points. You can change that at the top of the file

The plugin is rather simple and has a lot of room for improvements, but it seems to be working. Please let me know if it does what you want.

Post's attachments

Attachment icon 1.79 kb, 331 downloads since 2016-03-14 

Re: Independant variable for integration (to do Fourier Transform)

Thank you so much, Ivan! Will try it right away.

Re: Independant variable for integration (to do Fourier Transform)

Thank you again - it works great! I don't see how to use point series in a function so I've extended to add dB and phase outputs (it's attached). While I've not used Python before, its documentation and your code made that simple. That is very much appreciated!

Post's attachments

Attachment icon 2.25 kb, 309 downloads since 2016-03-17