Fourier Basis Vectors

In [25]:
import numpy as np
import matplotlib.pyplot as plt

N-th roots of unity

In [27]:
N = 8
W = np.exp(2.j*np.pi/N)
In [30]:
W**8
Out[30]:
(1.0000000000000009+0j)
In [31]:
(W**3)
Out[31]:
(-0.7071067811865477+0.7071067811865477j)
In [32]:
(W**3)**8
Out[32]:
(1.0000000000000018+0j)

DFT Matrix

In [33]:
def dftMatrix(N):
    W = np.exp(2.j*np.pi/N)
    M = np.zeros((N,N), dtype=np.csingle)
    for n in range(N):
        for k in range(N):
            M[k,n] = W**(-n*k)
    return M

Start with low-dimensional complex vector

In [ ]:
N = 5
M = dftMatrix(N)
In [ ]:
print( np.round(M, decimals=3) )

We can compute its inverse

In [ ]:
Minv = np.conj(M) / N
In [ ]:
print(np.round(M@Minv, decimals=1))

Higher-dimensional complex vectors

In [34]:
N = 128
M = dftMatrix(N)
In [35]:
k = 1
plt.figure(figsize=(12,4));
plt.plot(np.real(M[:,k]), 'bo-');
plt.plot(np.imag(M[:,k]), 'o-', color='lightblue');
plt.title(r'$W_{'+str(N)+'}('+str(k)+')$');
In [36]:
k = 2
plt.figure(figsize=(12,4));
plt.plot(np.real(M[:,k]), 'bo-');
plt.plot(np.imag(M[:,k]), 'o-', color='lightblue');
plt.title(r'$W_{'+str(N)+'}('+str(k)+')$');
In [37]:
k = 9
plt.figure(figsize=(12,4));
plt.plot(np.real(M[:,k]), 'bo-');
plt.plot(np.imag(M[:,k]), 'o-', color='lightblue');
plt.title(r'$W_{'+str(N)+'}('+str(k)+')$');

Let's try out the orthogonality

In [49]:
# Fourier basis vectors of DIFFERENT frequencies
M[:,3]@np.conj(M[:,17])
Out[49]:
(-1.2431988e-07+2.923755e-07j)
In [50]:
# Fourier basis vectors of the SAME frequencie
M[:,17]@np.conj(M[:,17])
Out[50]:
(128+0j)
In [ ]: