Lesson 7 of 15
Inverse DFT
Inverse Discrete Fourier Transform
The Inverse DFT (IDFT) reconstructs the original time-domain signal from its frequency-domain representation. It is defined as:
Notice:
- The exponent is positive (versus negative for DFT)
- There is a normalization factor
DFT–IDFT Round Trip
The DFT and IDFT are exact inverses (up to floating-point precision):
This round-trip property is essential for signal reconstruction after frequency-domain processing.
Example
Given :
Result: — a DC signal.
Your Task
Implement:
idft(X)— returns a list of real floats (take.realof each result)
import math
def idft(X):
N = len(X)
x = []
for n in range(N):
val = 0 + 0j
for k in range(N):
val += X[k] * math.e ** (2j * math.pi * k * n / N)
x.append((val / N).real)
return x
Verify the round trip: define dft from the previous lesson and check idft(dft([1,2,3,4])) ≈ [1,2,3,4].
Python runtime loading...
Loading...
Click "Run" to execute your code.