# inverse discrete FFT in python, multiple times?

I was wondering what really happens when taking the inverse discrete FFT on some set of numbers, for 3 times? Because looking at it, it looks like we're getting an output that is identically with the input, and I don't get why.

Also I was trying to implement my own inverse discrete Fourier transform in python, following wikipedia, looking at the IFFT provided by octave:

and at the plot provided by my code:

It just doesn't make any sense. Here is my code:

#!/usr/bin/python
import matplotlib.pyplot as plt
import numpy as np
import math

points = [24+0j, -18.39230+0.73205j, 8-3.46410j,
-2+4j, 0+0j, 2.39230-2.73205j, -4+0j, 2.39230+2.73205j, 0-0j,
-2-4j, 8+3.46410j, -18.39230-0.73205j]

def inverse_fourier_transform(points):
inversed_points = []
N = len(points)

for k in range(0, N):
s = 0.0
for n in range(0, N - 1):
s += points[n]*np.exp(1.j*2.0*np.pi*k*n/N)/N
inversed_points.append(s)

return inversed_points

inv_points = inverse_fourier_transform(points)
inv_points2 = inverse_fourier_transform(inv_points)
inv_points3 = inverse_fourier_transform(inv_points2)

x = []
y = []

for pt in inv_points3:
x.append(pt.real)
y.append(pt.imag)

plt.scatter(x, y, s=0.5)
plt.plot(x, y)
plt.show()

• Does this answer your question? Fourier transform 4 times = original function (from Bracewell book) – Matt L. Dec 22 '19 at 13:28
• As for your code, shouldn't k be in (0,N-1)? – Matt L. Dec 22 '19 at 13:37
• @MattL. I tried with swapping k and n, but it's actually worse – C. Cristi Dec 22 '19 at 17:44
• Why swapping? k should go from 0 to N-1, not to N. – Matt L. Dec 22 '19 at 18:18

Ignoring the scaling (or assuming $$1/\sqrt N$$). We have