Homework #5 pdf

HW-5
Jonathan King
May 1, 2014
1 Problem 1
1.1 Part a
The Fourier Rcoefficients of a function f(x)
= cos(6x) are given by
2π −imx
1 R 2π −imx 1 6ix
1
e
cos(6x)dx
=
e
+ e−6ix )dx
fˆm = 2π
0
2π 0
2 (e
R
R
fˆm = 1 [ 2π e(6−m)ix dx + 2π e−(6+m)ix dx]
4π
0
0
This will equal zero for every interger m, except for where
6 − m = 0 and 6 + m = 0
Thus, the only non-zero Fourier coefficients will occur for m = 6, −6.
1.2 Part b
For 10 sample points, any function with a frequency of 5 (over the interval from 0 to 2π)
can be represented perfectly. However, e6ix has a frequency of 6. Since we are dealing
with 2π periodic functions, e6ix will progress through 5 complete cycles, where it will
wrap around (or bounce off of) the Fourier coefficient of e−5ix and then complete one
more cycle (the sixth and final cycle), to give it an apparent frequency of 4 cycles per
2π.
ˆ = e4ix .
The interpolated frequency will have a frequency of 4, thus f (x)
2 Problem 2
2.1 Part a
Please see MATLAB code interpolation.m and interpolderiv.m
1
2.2 Part b
From the log-log plot of |sin(x)|3 we can see that the slope of the line approximates
p ≈ −2. Since this result is obtained from a log-log plot, we have algebraic convergence
of order 2 for the error for N weighted samples.
Recalling the previous homework, we know a function with k bounded, continuous
derivatives should have algebraic convergence of order k for the log-log plot of error
against N weighted samples. Thus, we expect the second derivative of |sin(x)|3 to have
a non-continuous derivative. This can be seen from the plot of the second derivative
2
thereby supporting the theorem.
3 Problem 3
Please see code slowFFT.m and FFT driver.m
A standard run of my FFT function against the native MATLAB function gave the
following times Elapsed time is 0.015090 seconds. Elapsed time is 10.375666 seconds
with the shorter time corresponding to Matlab’s function. Thus, for this vector, the
native library is about 1000 times faster than my function.
A standard run also gives the output
err norm =
1.252759678799600e-11
for the norm of the error of the 216 entry vector.
4 Problem 4
4.1 Part a
Please see MATLAB code extract.m
3
There is no observable periodicity in the graph of the original signal.
Running the signal through the Fast Fourier Transform and taking the magnitude of
the coefficients gives the following plot.
The indices of the terms with the largest coefficients by zooming in on the two largest
peaks. One such zoomed image is shown below.
4
The two indices obtained from the plot are 655 and 64883. However, Matlab indices
begin at 1, while Fourier indices begin with zero. Thus, the two dominant Fourier Indices
are 654, and 64882. The relationship of the indices is that there sum is equal to the total
number of samples.
To see why this occurs, consider our signal. Within the Fast Fourier Transform,
the signal will be treated as a periodic function. Thus, we can place the N2 to N-1th
th elements. For a signal with a single
elements in the same location as the −N
2 to 0
dominant frequency θ, the signal will be represented as the Fourier terms for fθ e−2πiθ/N
and f−θ e2πiθ/N which will be symmetric about zero. Note that the indices here are θ and
−θ where θ is an integer. Since the signal is periodic, we actually have θ and −θmodN .
The sum of these indices will equal 0modN , which is simply the total number of samples.
From this analysis, we can also see that the coefficients will be complex conjugates.
Note that the two exponentials in fθ e−2πiθ/N and f−θ e2πiθ/N are related by simply replacing i with −i. Since i only appears in the exponential of each term, this is equivalent
to taking the complex conjugate. A plot in the complex plane of the coefficients also
illustrates this fact.
5
requency
In class we showed that F reqsignal = Index·SamplingF
. Thus for this case,
N samples
654·44100
F = 654+64882
= 4400Hertz was the frequency of the signal.
5 Problem 5
5.1 Part a
Using the formula
N −1
fi gj−i modN we find that
(f ∗ g)j = Σi=0
f ∗ g = [1 + 0 + 0, 1 + 1 + 0, 1 + 1 + 1, 1 + 1 + 1, 0 + 1 + 1, 0 + 0 + 1]T = [1, 2, 3, 3, 2, 1]T
5.2 Part b
Using the same formula as in part a, we find
f 8g = [1 + 0 + 1, 1 + 1 + 0, 1 + 1 + 1, 1 + 1 + 1, 0 + 1 + 1, 1 + 0 + 1] = [2, 2, 3, 3, 2, 2]T
5.3 Part c
The answer to part a has the same non-zero vectors as the non-periodic convolution.
Thus we can see that, for two vectors of length N1 and N2 , each vector should be
padded to a length N1 + N2 − 1.
5.4 Part d
We are asked to prove that f ∗ g = g ∗ f In terms of the jth elements of the convolution:
(f ∗ g)j = Σi fi g(j−i)modN = Σi gi f(j−i)modN = (g ∗ f )j
If we can show that the jth element of each convolution is the same, then the two
convolutions are equal. We note that, since the summation is finite, the order of the
6
terms in each summation is unimportant. Thus, we need only show that the same term
in f is paired with the same term in g for each convolution.
For (f ∗ g)j = Σi fi g(j−i)modN , let k = (j-i) modN and thus, i = (j-k)modN. This gives
(f ∗ g)j = Σi f(j−k)modN g(k) Note that the kth element of g is paired with the j −
kmodN element of f.
For (g ∗ f )j = Σi gi f(j−i)modN , the ith element of g is paired with the j − imodN
element of f. Note that there is nothing inherently meaningful in the choice of i and k as
subscripts. If we choose a filler subscript of q, then the qth element of g is always paired
with the j − qmodN element of f.
Thus, the same elements are always paired together, which, as previously stated, is
sufficient to show that the the convolution function commutes.
5.5 Part e
The sum of the signal f ∗ g will be equal to product of the sum of the signal of f, with
the sum of the signal of g. We can see from the formula for (f ∗ g)j that each element
in f will be paired with each element in g in exactly one summation. Thus, taking the
sum of the summations will give
f0 g0 + f0 g1 + ...f0 gN −1 + f1 g0 + ...fN −1 g0 + ...fN −1 gN −1
This can be factored to
f0 (g0 + g1 + ...gN −1 ) + f1 (g0 + g1 + ...gN −1 ) + ...fN −1 (g0 + g1 + ...gN −1 )
= f0 (sum of g) + f1 (sum of g) + ...fN −1 (sum of g)
= (f0 + f1 + ...fN −1 )(sum of g) = (sum of f)(sum of g).
Thus, the sum of the signal will equal the product of the sum of the signal of f with
the sum of the signal of g.
6 Problem 6
Please see MATLAB code reverb.m
zelda.wav was the input file
output.wav is the output
7 Problem 7
Please see MATLAB code deblur.m
Without the deconvolution, the image is
7
Running the deconvolution gives the crisp image
Introducing iid noise changes the image to
8
This deconvolution is very sensitive to noise because some of the element in the DFT
of the aperture image are very small and on the order of the size of the introduced noise.
Thus, when the code reaches the step — blur ./ aper — and divides the DFT of the
blurred image by the DFT of the aperture image, the change in the signal (despite being
very small), is large compared to the small size of aperture denominator. The relatively
small value of the denominator causes the value to spike when subsequently run through
the inverse FFT. The improperly large value that results from the inverse FFT then
gives rise to the improperly represented crisp image.
8 Attribution
I worked with Pawan Dhakal.
9