Here they are: pdf

## AMAT 415 — Assignment 3 solutions

Here they are: a3solns

As usual, please report any errors, typos, etc.

## AMAT 415 — Week 9 problems

50) Find the -transform of the sequence . (Give a closed-form expression.)

51) Let be as in the previous problem.

- Find two signals and such that . (You might consider letting be a -spike.)
- If , can you find a such that ?
- Can you a solution with causal signals find and such that both and have infinitely many nonzero components and ? (You might consider -transforms for this last part.)

52) Find a simple expression for , where

.

53) Show that the -transform of the sequence

is .

(Problems 52 and 53 are from Chapter 5.1 of *Transform methods in applied mathematics*, by Lancaster and Salkauskas.)

## Matlab activity 7: Sliding FFTs

Our previous MATLAB activities have dealt primarily with the study of periodic signals. The theory of Fourier series tells us that periodic signals can be represented as sums of the simplest kinds of periodic signals — sines and cosines.

This makes less sense for aperiodic signals, the signals we’ve began studying last week. To see this, let’s look at an example:

**t=1/4096:1/4096:1;
f1 = 300;
x=cos(2*pi*f1*t.^2);
plot(t,x)
**

(Note the t.^2 inside the cosine.) A cosine wave of (constant) frequency is given described by the equation . The function is a cosine function of “variable” frequency. Near , it’s frequency is roughly . (Such a sound is called a “chirp”. There is actually a MATLAB command

**chirp**that makes these kinds of signals.) Take a look at some “zoomed in” plots:

**x1=x(2000:2199);
plot(x1);
hold on;
x2=x(3000:3199);
plot(x2,’red’);
x3=x(3897:4096);
plot(x3,’green’);
**

(Maybe try looking at them on separate plots too.) These look more like standard sinusoids. Approximately what are their frequencies?

If these zoomed in pieces of the signal x do indeed behave like sinusoids, then their FFTs should gives sharp spikes close to their frequencies. Do they?

**X1=fft(x1);
X2=fft(x2);
X3=fft(x3);
hold off;
hold on;
plot(abs(X1))
plot(abs(X2),’red’);
plot(abs(X3),’green’);
**

Compare these plots with that of the FFT of the entire signal

**x**:

**hold off
X4=fft(x);
plot(abs(X4));
**

What is this plot trying to tell us? A lot of frequencies seem to be present. The spectrum is spread out between frequencies of 0 and like 900 cycle/second, where there is a steep dropoff. (This is sort of strange because our “variable frequency cosine wave” has frequency varying between 0 and 300 cycles/second.) From the plot in the time domain (the plot of

**x**vs

**t**), we saw that

**x**oscillates very slowly near and that the rate of oscillation increases as t increases. This information cannot be read off this last plot. (At least I don’t see how to do it…)

The FFT is a great tool for reading off information about the frequency domain composition of signals so long as this composition isn’t varying too quickly. This means we should only perform FFTs on relatively short time intervals. Since our “variable frequency cosine wave” has its frequency varying between 0 and 30, and we know we should always sample at more than two times as great as the highest frequency component, let’s do FFTs of length 256=2^8. The simplest thing to do is to break our signal up into 16=**length(x)/256** blocks of 256 samples, take the FFT of each, and “assemble the results”.

**A = zeros(256,16);**

for k = 1:16

xx = x((k-1)*256+1:k*256);

A(:,k)=fft(xx);

end

**image(abs(A’))
**

The vertical axis along the bottom tells us which block’s FFT we’re looking at. The horizontal axis is frequency (scaled in a strange way, let’s not bother with that for the moment.) The color intensity indicates the strength (or amplitude or volume) of a given frequency within a given block. You should see a bright line sloping downwards from the top left and another one sloping downwards from the top right. The brightness indicates that our signal contains a dominant frequency component that is increasing as we move from block to block, i.e., as time progresses. This is the behavior we expect from our variable (increasing) frequency cosine wave. (The bright line sloping downwards from the top left comes from the symmetry of the Fourier transform. It gives no new information.)

This picture is still very rough, and it’s tough to read quantitative information off of it. First, the resolution is a little grainy because we only have 16 blocks along the horizontal axis. We can remedy this to an extent by allowing out blocks to overlap: Instead of our first FFT being samples 1 to 256, our second being 257 to 512, etc., we instead slide along our FFT window of length 256 by a smaller increment each time: Our first FFT would still be calculated from samples 1 to 256, but our second may be say from 128 to 384, and the third from 256 to 512, … I won’t make you code this process by hand. MATLAB has a built in function for exactly this: **spectrogram**. (The picture it gives you is also called a spectrogram.) Here’s the syntax:

**spectrogram(x,256,128,256,4096)
**

(Note that the spectrogram has the axes interchanged: It has frequency on the horizontal axis and time on the vertical.) The first 256 is the “window” which for us at the moment is the same as the other 256, just the length of the FFT (the number of samples used to compute it). 128 is the overlap between each successive FFT. Thus, as stated there is 50% overlap between each FFT. 4096 is the sampling rate — just the length of

**x**since our

**t**ran from 0 to 1. Play around with the parameters and see what happens.

Try a different **x**:

**x=cos(2*pi*f1*t.^3);
spectrogram(x,256,128,256,4096);
**

In the next weeks, we’ll touch on a few ways to optimize these spectrograms — make them smoother, have better resolution, less noise, etc. But for now I just wanted to introduce the notion. The spectrogram is one of the most useful and pervasive methods for visualizing frequency composition of aperiodic signals. The key is that it shows three parameters simultaneously — time, frequency (frequencies present in the signal at a given time) and intensity/amplitude/power of the signal.

*The takeaway sentence from this exercise is:* Since frequency composition of aperiodic signals is roughly constant over short enough time intervals, we can use our tools (FFT) for analyzing periodic signals — those whose frequency composition is constant over long intervals — in blocks for analyzing aperiodic signals.

## AMAT 415: Assignment 3

Please submit the following problems: 28, 33, 38, 42, 47.

And: In MATLAB activity 6, you investigated the function graphically. Along which line segments is discontinuous? Explain why.

Each problem is graded out of 2 points.

## AMAT 415 — Matlab activity 6: Complex logarithms

If is a real number, then is an unambiguously defined real number if . One reason for this is that is the inverse function of , an increasing and therefore one-to-one function.

In the complex realm, is not well defined, echoing the fact the function is not one-to-one. (It’s periodic with period and thus -to-one.)

To unambigiously define a complex logarithm, we must choose an interval in which to measure the angles of complex numbers: If , then there is a unique such that . We can define a branch of logarithm subordinate to this choice by the rule . Although defined for all nonzero , this branch of the logarithm is discontinuous along the ray , .

A standard choice is , putting in , and this is what MATLAB uses when computing logarithms using the command **log**. To “see” the discontinuity of this branch of the logarithm along , — the negative real axis — try this:

**>> h = 0.01;
>> x = -3:h:3;
>> A = ones(1,length(x))’*x;
>> B = A+i*A’;
>> C = log(B);
>> m = -min(min(imag(C)));
>> image(x,x,10*(imag(C)+m)); % We can’t plot a complex function of a complex variable!
**

How is does the discontinuity manifest itself on the picture? Is the discontinuity evident from the following plots? Why or why not?

**>> image(x,x,10*(real(C)+m));
>> image(x,x,10*(abs(C)+m));
**

Since the logarithm function is discontinuous, functions defined in terms of it will also tend to be discontinuous. Let’s look at , for example.

**>> x = -10:h:10;
>> A = ones(1,length(x))’*x;
>> B = A+i*A’;
>> C = log(exp(B)+1);
>> m = -min(min(imag(C)));
>> image(x,x,10*(imag(C)+m));
**

What do you conclude from this picture about the location of the discontinuities of ? Try to confirm your claim theoretically. What if you replace

**imag**by

**angle**in the above snippet? What do you observe? Can you “explain” your observations?

Since the logarithm comes in many branches, so do functions that are defined using the logarithm, e.g., power functions: , , . Here, is defined to be where, implicitly, we have chosen a branch of . (This choice of branch doesn’t matter when $s$ is an integer. Why?) Let’s consider the case .

**>> x = -3:h:3;
>> A = ones(1,length(x))’*x;
>> B = A+i*A’;
>> C = exp(1/2*log(B));
>> m = -min(min(imag(C)));
>> image(x,x,10*(imag(C)+m));**

So is discontinuous along a ray. Thought question: Without mentioning logarithms, can you explain why a square root function cannot be continuous on the entire complex plane? You might want to consider how square roots behave on the unit circle.

Here another fun one:

**>> C = log(1/2*(B.^2-1));
>> m = -min(min(angle(C)));
>> image(x,x,10*(imag(C)+m));**

Can you explain the discontinuities?

FOR 2 BONUS POINTS ON ASSIGNMENT 3: There is a branch of the logarithm making continuous (and analytic) on . Which one is it? Justify your answer.

## AMAT 415 — Week 8 problems

40) Find the first 5 terms of the Taylor series of around .

41) Find the Taylor series of around . (Suggestion: Use the identity .)

42) Find the first four nonzero terms in the Taylor series of

around .

43) Find the Taylor expansion of

around . (Suggestion: First do a partial fraction decomposition.)

44) Find the Taylor expansion of

around .

45) Find the first 5 nonzero terms in the Laurent expansion of around .

46) Find the terms of nonpositive index in the Laurent expansion of

around .

47) Find the points where

is singular (i.e. not analytic). Find its residues at those points.

48) Same as the previous question, but with

.

49) Same as the previous question, but with

.

## AMAT 415 — Tutorial 6 activity

Here is the activity: pdf

Rejoice! I couldn’t think come up with a worthwhile MATLAB-centric activity relevant to what we’ve been doing lately in class. But MAPLE or MATHEMATICA might come in handy…

## AMAT 415 — Weeks 6 & 7 problems

*Please report typos and errors by email.*

28) Find all the solutions of . (Hint: Rewrite the equations in terms of exponentials and manipulate it into a quadratic equation in the variable .)

29) Suppose is analytic on . Let . For which is analytic? (Hint: Use the Cauchy-Riemann equations.)

30) Suppose is analytic on . Let . For which is analytic?

31) Find a function such that and is analytic.

32) Sketch and describe in a few words the paths , , and , .

33) Evaluate , where is the union of the line segments joining to and then to .

34) Evaluate , where is the part of the unit circle joining to in a counterclockwise direction.

35) Evaluate , where is the unit circle traversed counterclockwise.

36) In class, we showed that , where , . Identify the flaw in the following argument: Since is an antiderivative of , the fundamental theorem of calculus implies that .

37) Evaluate where is the circle centered at with radius . (Hint: Deform the path into a more convenient one.)

38) Evaluate , where is the (a) circle or radius centered at ; (b) the circle of radius centered at ; (c) the circle of radius centered at .

39) Let

.

Show that

.

Conclude that is not continuous at . (Hint: Use the definition of the derivative to compute .) Challenge: Adapt this exercise to construct a function such that , , , exist but such that is discontinuous at .

## AMAT 415 — Matlab activity 5: Downsampling, upsampling and interpolation

(As usual, please report errors or typos by email.)

Let’s plot the cosine wave of frequency 60 Hz, sampled 1000 times per second for 1 second:

**t = 0:0.001:1-0.001;**

** x = cos(2*pi*60*t);**

** plot(t,x);**

(Maximize your figure window if the graph is to squooshed.) Now let’s plot the same wave, sampled at 200 times per second for one second. There are two ways to do this. One way is to proceed as above:

**tt = 0:0.005:1-0.005;**

** xx = cos(2*pi*60*tt);**

** plot(tt,xx);**

Alternatively, MATLAB builds in functionality to downsample by a factor of n, i.e., to keep 1 out of every n samples

starting with the first one. We want 200=1000/n, so n=5.

**tt = downsample(t,5);**

** xx = downsample(x,5);**

** plot(tt,xx);**

To compare the graphs, it helps to plot them one below the other. To do this, type:

**subplot(2,1,1);**

** plot(t,x);**

** subplot(2,1,2);**

** plot(tt,xx);**

(Look up subplot in the online help for an explanation of the syntax.)

The graphs look pretty similar, at least in the sense that both graphs seem to be displaying waves of the same frequency. So it seems that we didn’t lose that much information by downsampling by a factor of 5.

Now let’s see what happens when we downsample by a factor of 10:

**xx = downsample(x,10);**

** tt = downsample(t,10);**

** subplot(2,1,2);**

** plot(tt,xx);**

Now the graphs look significantly different. If you count the peaks (local maxima) on the downsampled graph — both the sharp ones and the squared off ones — you should count 40 of them. This doesn’t sound right for a cosine wave that’s supposed to have frequency 60 Hz. The problem here is aliasing. Since 60 (frequency of wave) > 100/2 (half the sampling rate), our wave is aliased with one of frequency 100 – 60 = 40 Hz. The aliasing can also be seen in the frequency domain.

**y = fft(x);**

** yy = fft(xx);**

** subplot(1,2,1);**

** stem(0:99,abs(y(1:100))/1000); % just plotting frequencies up to 100 to make the picture clearer**

** subplot(1,2,2);**

** stem(0:49,abs(yy(1:50))/100);**

Note the locations of the spikes. In summary: For applications like data compression, it is often desirable to downsample a signal. When doing this, you need to be aware of the aliasing phenomena that can creep in.

The process opposite to downsampling is upsampling — increasing the number of samples/second of a prerecorded signal.

Upsampling is closely related to (and sometimes used synonymously with) interpolation.

Close the figure window to start fresh.

Suppose we sample a signal 20 times per second and obtain the following:

**x = [-4.0000,**

** 5.2802,**

** -6.5403,**

** 3.3084,**

** 2.2331,**

** -3.0000,**

** 4.0872,**

** -0.2183,**

** -1.6862,**

** -0.4261,**

** 2.0000,**

** -6.8983,**

** 5.9223,**

** -2.6904,**

** -0.6151,**

** 5.0000,**

** -2.4692,**

** 0.8363,**

** 1.0682,**

** -1.1919];**

Make x a row vector:

**x = x’;**

How might we fit a curve to this data set? How can we “connect the dots” in the stem plot in a reasonable way? The output of

**plot(0:0.05:0.95,x);**

isn’t very satisfying — too jagged. Upsampling gives a way. Try:

**xx = upsample(x,5);**

** stem(xx);**

What we’ve just done is just upsampled x by a factor of 5, i.e., stuck 4 zeros between each component of x. The plot doesn’t look any better than the last one, though. But now let’s pass to the frequency domain. First, we examine the spectrum of our original signal x:

**y = fft(x);**

** subplot(1,2,1); % we’ll add another plot below**

** stem(0:19,abs(y));**

The plot suggests that our signal is a superposition of sinusoidal components of frequencies 2, 7, and 9 Hz. (Recall that we can only resolve frequencies less than half the sampling rate, in this case 10=20/2.)

Now let’s examine the spectrum of the upsampled signal xx:

**yy = fft(xx);**

** subplot(1,2,2);**

** stem(0:99,abs(yy));**

What do you observe? (Maximize the figure window if the plot is to squooshed.)

The spectrum is a bunch of (5, actually) copies of the spectrum of the original signal lined up. If we kill the extra copies, we’re left with the spectrum of our original signal, but at a higher resolution.

**w = ^{1};**

The inverse Fourier transform of w.*yy interpolates x nicely:

**z = ifft(w.*yy); % this is the same as the convolution of xx with ifft(w)**

** plot(0:0.01:0.99,5*real(z),’red’);**

** hold on;**

** stem(0:0.05:0.95,x);**

So we have found a “nice” smooth curve interpolating the data set x using Fourier analysis.

This is an illustration of a standard method for recovering a continuous signal from a sampled version. This method is the content of the famous Shannon Sampling Theorem. Time permitting, we’ll talk a bit about that towards the end of the course.

*FOR 2 BONUS POINTS ON HOMEWORK 3:* In the last snippit of code, I’m plotting 5*real(z) as opposed to just z. Can you explain the presence of this correction factor conceptually? (“Because it makes the picture look right” is not sufficient.)

- 1:100) < 21);

**stem(0:99,w.*abs(yy [↩]**

**
Posted in Uncategorized
1 Comment
**