# Radix 2 Inverse FFT

Due to the strong duality of the Fourier Transform, adjusting the output of a forward transform can produce the inverse FFT. Data in the frequency domain can be converted to the time domain by the following method:

- Find the complex conjugate of the frequency domain data by inverting the imaginary component for all instances of K.
- Perform the forward FFT on the conjugated frequency domain data.
- Divide each output of the result of this FFT by N to give the true time domain value.
- Find the complex conjugate of the output by inverting the imaginary component of the time domain data for all instances of n.

**Note***: both frequency and time domain data are complex variables. Typically the imaginary component of the time domain signal following an inverse FFT is either zero, or ignored as rounding error. Increasing the precision of variables from 32-bit float to 64-bit double, or 128-bit long double significantly reduces rounding errors produced by several consecutive FFT operations.*

**Code Example (C/C++)**

#include <math.h> #define PI 3.1415926535897932384626433832795 // PI for sine/cos calculations #define TWOPI 6.283185307179586476925286766559 // 2*PI for sine/cos calculations #define Deg2Rad 0.017453292519943295769236907684886 // Degrees to Radians factor #define Rad2Deg 57.295779513082320876798154814105 // Radians to Degrees factor #define log10_2 0.30102999566398119521373889472449 // Log10 of 2 #define log10_2_INV 3.3219280948873623478703194294948 // 1/Log10(2) // complex variable structure (double precision) struct complex { public: double Re, Im; // Not so complicated after all }; void rad2InverseFFT(int N, complex *x, complex *DFT) { // M is number of stages to perform. 2^M = N double Mx = (log10((double)N) / log10((double)2)); int a = (int)(ceil(pow(2.0, Mx))); int status = 0; if (a != N) // Check N is a power of 2 { x = 0; DFT = 0; throw "rad2InverseFFT(): N must be a power of 2 for Radix 2 Inverse FFT"; } complex *pDFT = DFT; // Reset vector for DFT pointers complex *pX = x; // Reset vector for x[n] pointer double NN = 1 / (double)N; // Scaling factor for the inverse FFT for (int i = 0; i < N; i++, DFT++) DFT->Im *= -1; // Find the complex conjugate of the Frequency Spectrum DFT = pDFT; // Reset Freq Domain Pointer rad2FFT(N, DFT, x); // Calculate the forward FFT with variables switched (time & freq) int i; complex* x; for ( i = 0, x = pX; i < N; i++, x++){ x->Re *= NN; // Divide time domain by N for correct amplitude scaling x->Im *= -1; // Change the sign of ImX } }

Found a mistake? Have a question or improvement idea?
Let me know.

Table Of Contents