Math 4330, Homework 3, 2/5/2014

advertisement
Math 4330, Homework 3, 2/5/2014
1
Read 4.3.3.C (up to the middle of page 306 Do a web search to learn a little about
complex numbers in Python (2.7). Then do the following:
1. Write a function print_comp_list(zlist) which takes as input a list zlist of complex numbers and prints them out, comma-separated, to three decimal places.
2. Write a function DFT(u) which takes as input a list u of complex numbers, computes
and returns their DFT using Equation (35) from Knuth.
3. Create a list u containing the sequence of complex numbers 0,1,0,-1,0,1,0,-1. Print u,
DFT(u), and DFT(DFT(u)).
4. Roughly how many operations would your DFT function require to compute the Discrete
Fourier Transform of a list of 106 complex numbers? Roughly how many operations
would a Fast Fourier Transform require to do the same?
5. Find at least 4 distinct interesting applications of the DFT/FFT. (You need not describe the applications in detail - one or two sentences about each will suffice)
The following code addresses questions 1-3:
import cmath
def print_comp_list(zlist):
print "[",
for z in zlist:
print "%.3f+%.3fI, " % (z.real, z.imag),
print "]"
def DFT(u):
K = len(u)
w = cmath.exp(complex(2*cmath.pi*complex(0,1)/K))
uh = [0 for l in range(K)]
for s in range(K):
temp=complex(0,0)
for t in range(K):
temp += w**(s*t)*u[t]
uh[s] = temp
return uh
u=[0,1,0,-1,0,1,0,-1]
1
c
This document is copyright 2014
Chris Monico, and may not be reproduced in any form without
written permission from the author.
1
print u
uh = DFT(u)
print_comp_list(uh)
uhh = DFT(uh)
print_comp_list(uhh)
For question 4, the DFT requires about (a small multiple of) 1012 operations, while the
FFT requires about (a small multiple of) 106 log2 (106 ) ≈ 2 · 107 operations.
2
Download