2

I'm trying to calculate the inverse Fourier Transform of two real functions with a single IFFT. The best and most straightforward explanation I've found so far is here, where it says:

Use the fact that the FFT is linear and form the sum of the first transform plus i times the second. You have two vectors, x1 and x2, with discrete Fourier Transforms X1 and X2 respectively. Then

x1 = Re[ IDFT[ X1 + i X2 ] ]

and

x2 = Im[ IDFT[ X1 + i X2 ] ].

The problem is that I don't get where the 'i' parameter comes from. Any hint on this would be much appreciated.

Thanks in advance.

EDIT:

After doing some experiments I finally made it work, but now I'm more confused than before as it didn't work as I expected and had to use some imagination to figure out the correct formulas.

I just made up a new complex array where:

Re[n] = X1Re[n] - X2Im[n]
Im[n] = X2Re[n] + X1Im[n]

After doing an IFFT on it x1 = Re and x2 = Im, so wouldn't it be correct to express it like this?

x1 = Re[ IDFT[ X1 - i X2 ] ]
x2 = Im[ IDFT[ X2 + i X1 ] ].
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Trap
  • 12,050
  • 15
  • 55
  • 67
  • 1
    Just out of interest, what is the use case for doing an IFFT on real data ? While real-valued time domain signals are of course very common I've never seen purely real frequency domain signals ? – Paul R Jun 14 '11 at 22:50
  • The IFFT is made on the output of a single FFT which was fed with two real signals. Sorry I think I didn't make myself clear :) – Trap Jun 14 '11 at 23:18
  • @eryksun You're right I transcribed it wrong, thanks – Trap Jun 15 '11 at 07:25
  • 1
    [Here's a related question.](http://stackoverflow.com/questions/3959289/efficient-2d-fft-on-real-input-data) – Peter K. Jun 18 '11 at 13:19

2 Answers2

4

Are you wondering what the 'i' represents? In this case, I believe 'i' is referring to sqrt(-1), the imaginary unit vector.

Then:

Re[ IDFT[ X1 + i X2 ] ]

will be the 'real' part of that transform (anything without an 'i') and

Im[ IDFT[ X1 + i X2 ] ]

will be the 'imaginary' part of that transform (anything multiplied by an 'i').

It is possible I've misunderstood your question and this answer is much too simplistic; if it is, no insult was intended to your intelligence, I just misunderstood you.

uscere90
  • 543
  • 1
  • 5
  • 12
  • The "plus i times the second" part is what keeps me wondering. I'm no math guru nor I pretend to be, I just want to add this functionality to my FFT lib while having a little understanding of what it's really doing :) – Trap Jun 14 '11 at 22:26
  • 2
    It's because of the linearity of FFT, which means it respects addition and scalar multiplication. (i.e. F(a + bc) = F(a) + cF(b). You can exploit this to write your 2 transforms as 1. So instead of doing F(a) first and F(b) next, you do F(a +bi), and then F(a) = anything without an i, and F(b) = anything with an i. 'i' in this case just works like any constant. It's like.... a really advanced way of rewriting (x - 2x + 2) as (x - 2x + 1) + 1 so you can write (x-1)^2 + 1. They're all the same thing, it's just easier to work with one of them. – uscere90 Jun 14 '11 at 22:31
1

If you want to ignore the mathematics of complex variables, multiplying by i is just notation for how you swap and scale a pair of vectors to produce another pair of vectors. And the complex vectors X1 and X2 can each be considered to be just pairs of real-valued vectors (with a "complex" relationship under the transforms of interest). The swap and scale makes the two component vectors more easily separable, after some arithmetic and transforms, into the real valued vector of interest.

hotpaw2
  • 70,107
  • 14
  • 90
  • 153