Solutions 020812

download Solutions 020812

of 248

Transcript of Solutions 020812

  • 8/2/2019 Solutions 020812

    1/248

  • 8/2/2019 Solutions 020812

    2/248

    2

    Copyright c1999Edward A. Lee and Pravin Varaiya

    All rights reserved

  • 8/2/2019 Solutions 020812

    3/248

    Contents

    1 Signals 1

    2 Defining Signals and Systems Solutions 11

    3 State Machine Models Solutions 21

    4 Composing State Machines 29

    5 Linear Systems 41

    6 Hybrid Systems Solutions 49

    7 Frequency Domain Solutions 61

    8 Frequency Response Solutions 69

    9 Filtering Solutions 81

    10 The Four Fourier Transforms Solutions 95

    11 Sampling and Reconstruction Solutions 111

    12 Stability 115

    13 Laplace and Z Transforms 121

    14 Composition and Feedback Control 135

    3

  • 8/2/2019 Solutions 020812

    4/248

    4 CONTENTS

    A Sets and Functions 143

    B Complex Numbers 147

    C Laboratory Exercises Solutions 157

    C.1 Arrays and sound solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    C.1.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    C.1.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

    C.2 Images solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

    C.2.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

    C.2.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

    C.3 State machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

    C.3.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

    C.3.2 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

    C.3.3 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177

    C.4 Control Systems Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

    C.4.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

    C.4.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

    C.5 Difference Equations Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    C.5.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    C.5.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    C.6 Differential Equations Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

    C.6.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

    C.6.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

    C.7 Spectrum Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

    C.7.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

    C.7.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

    C.8 Comb Filters Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

    C.8.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212

    C.8.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

  • 8/2/2019 Solutions 020812

    5/248

    CONTENTS 5

    C.9 Plucked String Instrument Solutions . . . . . . . . . . . . . . . . . . . . . . . . . 218

    C.9.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

    C.9.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

    C.10 Modulation and Demodulation Solution . . . . . . . . . . . . . . . . . . . . . . . 227

    C.10.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227

    C.10.2 Independent section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

    C.11 Sampling and Aliasing Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

    C.11.1 In-lab section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236

  • 8/2/2019 Solutions 020812

    6/248

    6 CONTENTS

  • 8/2/2019 Solutions 020812

    7/248

    Chapter 1

    Signals

    1. (a) x [Integers Reals] given by

    n Integers, x(n) = n

    (b) x [Reals Reals2] given by

    t Reals, x(t) = (t, 2t)

    (c) x [{0, 1, , 600} {0, 1, , 400} {0, 1, , 255}] given by

    (m, n) {0, 1, , 600} {0, 1, , 400}, x(m, n) = (m + n) mod 255(d) [{0, 1, , 600} {0, 1, , 400} {0, 1, , 255}] is the appropriate signal space

    for images of size 600 400 pixels with an 8-bit color map index.2. (a) One possible model is

    CarBatteryVoltage :Reals Reals

    where the domain represents time and the range represents voltage, and

    t Reals, CarBatteryVoltage (t) = 12.

    Since the value is contant, we could have defined the range to be {12}, a set with just oneelement. However, in practice, the voltage is only approximately a constant 12 volts. In

    fact, while you are starting your car, the electrical load on the battery causes the voltage

    to drop considerably. The voltage also fluctuates with noise caused by electrical circuits

    in the car. Thus, setting the range to Reals gives us more modeling flexibility, allowing

    us to be more accurate if we choose to do so. A sketch is shown below:

    1

  • 8/2/2019 Solutions 020812

    8/248

    2 CHAPTER 1. SIGNALS

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

    2

    4

    6

    8

    10

    12

    time (sec)

    voltage

    This is generated by the following Matlab commands

    plot([0 1],[12 12])

    xlabel(time (sec))

    ylabel(voltage)

    axis([0 1 0 13])

    (b) One possible model is

    price:Naturals Priceswhere the domain counts off days from some starting point, and the set Prices is

    Prices = {0, 1/16, 1/8, 3/16, 2/8, 5/16, },assuming the stock markets have not yet switched a decimal system. A sketch of a

    segment of one such possible function (for a fictitious company) is shown below:

    0 5 10 15 20 25 3040

    41

    42

    43

    44

    45

    46

    47

    day

    price

    This is generated by the following Matlab commands

  • 8/2/2019 Solutions 020812

    9/248

    3

    days = 1:30;

    for day = daysprice(day) = 40 + day*0.2 + rand(1);

    end

    plot(days, price), xlabel(day), ylabel(price)

    (c) One possible model is

    position:Reals [0, L]where the domain represents time and L is the length of the road. A sketch of a segmentof one such possible function (which assumes that the car is moving forward in fits and

    starts) is shown below:

    0 5 10 15 20 25 300

    2

    4

    6

    8

    10

    12

    14

    time

    pos

    ition

    This is generated by the following Matlab commands

    numSamples = 30;

    times = 2:numSamples;

    position(1) = 0;

    for t = times

    position(t) = position(t-1) + rand(1);end

    plot([1 times], position), xlabel(time), ylabel(position)

    (d) One possible model is

    twoPositions:Reals [0, L] [0, L]

    where the domain represents time and L is the length of the road. A sketch of a segmentof one such possible function (which assumes that both cars are moving forward in fits

    and starts) is shown below:

  • 8/2/2019 Solutions 020812

    10/248

    4 CHAPTER 1. SIGNALS

    0 5 10 15 20 25 300

    2

    4

    6

    8

    10

    12

    14

    16

    18

    time

    position

    Here, the function is represented as two functions,

    onePosition:Reals [0, L],

    anotherPosition:Reals [0, L],such that

    t Reals, twoPositions(t) = (onePosition(t), anotherPosition(t)).

    These are both plotted on the same plot, although it would equally valid to plot them in

    separate plots. This is generated by the following Matlab commands

    numSamples = 30;

    times = 2:numSamples;

    position1(1) = 0;

    position2(1) = 4;

    for t = times

    position1(t) = position1(t-1) + rand(1);

    position2(t) = position2(t-1) + rand(1);

    end

    plot([1 times], position1, -, [1 times], position2, --)

    xlabel(time), ylabel(position)

    (e) One possible model is

    stereoAudio:Reals Reals Reals

    where the domain represents time and the range represents air pressure at each of the

    two ears. Just as with the previous part, we can divide the function into two and plot the

    two functions separately or on the same plot.

    3. The sampling frequency is 44,100 Hz, so the sampling period is 1/44100 22 s.4. The four signals are shown in figure 1.1.

  • 8/2/2019 Solutions 020812

    11/248

    5

    -1 1t

    Triangle

    -1 1t

    -1 1

    t

    1

    0

    Step

    Sum

    1-1 1

    t

    Diff 1

    -10

    0

    Figure 1.1: The graphs of the signals for Problem 4. Three of the signals

    are discontinuous at 0; the solid dots marks the value of these signals at 0.

    5. (a) One possible model is

    PhotoImage: [0, width]

    [0, height]

    Intensity3

    where Intensity = [0, maxIntensity] for some constant maxIntensity. The three inten-sities in the range represent the amount of red, green, and blue, respectively, where 0

    represents white (the color is absent) and maxIntensity represents the maximum amount

    of the color that the photographic material can deliver. To get black, all three colors are

    set at their maximum. Note that an image displayed on a computer screen works in the

    opposite way. To get black, the three colors are set to their minimum.

    (b) The difference here compared to the previous part is that everything is discrete. One

    possible model is given in the text,

    ColorComputerImage:DiscreteVerticalSpace

    DiscreteHorizontalSpace

    Integers83

    so each pixel value is an element of{0, 1, , 255}3.(c) One possible model is

    SurfaceHeight:Longitudes Lattitudes [Hmin, Hmax]

    where Longitudes = [0, 360) and Lattitudes = [90, 90] (using units of degrees), andHmin = 36, 210 (the altitude in feet of the bottom of the Challenger Gorge of theMariana Trench), and Hmax = 29, 028 (the altitude in feet of the summit of MountEverest.

  • 8/2/2019 Solutions 020812

    12/248

    6 CHAPTER 1. SIGNALS

    (d) One possible model is

    ChairLocation: {1, 2, , N} [0, roomWidth] [0, roomLength],

    where we have numbered the chairs 1 to N. There are many other valid models. Forexample, we might construct a function

    Chairs: [0, roomWidth] [0, roomLength] {0, 1}

    and define it so that the value at a location in the room is 0 if there is no chair at that lo-

    cation and 1 if there is. The choice of model depends on how we will use the model. The

    first model, for example, makes it easier to track chair locations as they move around the

    room. In the second model, we lose the identity of the chairs, but can easily determine

    which parts of the room are not covered by some chair.

    6. Take the domain to be [6, 6] [6, 6] for a twelve-inch square with center at (0, 0). Takethe range to be Intensity3 for RGB values. Then for all (x, y) [6, 6]2,

    Albers(x, y) =

    (ry, gy , by), (x, y) [4, 4]2(rw, gw, bw), otherwise

    where (ry, gy, by) are the RGB values for the color yellow, and (rw, gw, bw) are the RGBvalues for white.

    7. The number of bits in the image is 1024

    768

    16 = 12, 582, 912. It would take 12582912/28000 =449 seconds to download over a 28 Kbps modem, 32.7 seconds over a 384 Kbps modem, and1.25 seconds over a 10 Mbps LAN.

    8. (a) In one possible model, the domain is {1, , 100} and the range is {Heads, Tails}. Onepossible event sequence is

    Heads,Heads, Tails, ,Heads.

    (b) A good choice for the domain is Naturals, since (ideally) the elevator starts functioning

    at some point in time and never stops. The range might be

    {Basement, 1, mezzanine, 2, 3, 4, 5, OpenDoor, CloseDoor,Alarm}.Any sequence from this set is a possible event sequence.

    (c) Again, a good choice for the domain is Naturals, since (ideally) the machine starts

    functioning at some point in time and never stops. The range might be

    {5, 10, 25, selectCoke, select7Up, releaseSoda}.

    The numbers represent received coins. Any sequence from this set is a possible event

    sequence.

  • 8/2/2019 Solutions 020812

    13/248

    7

    (d) A simple choice would be to represent the response as a voice signal. However, this fails

    to capture the key structure. Directions consist of a sequence of steps. A more detailedmodel would represent this sequence of steps. A reasonable choice for the domain is

    Naturals, since there is, in theory, no upper bound on the number of steps you might

    give. The range is a bit more complicated, since we have to decide what are possible

    directions. Clearly we would want to include things like go two blocks and turn left on

    University Avenue. This suggests that the range is a rather large set. It has to include

    elements go n blocks for all n Naturals and turn left at a for all street names a.Obviously we would also need turn right at a. We may even want to include thingslike take a hard left and go m miles for all m Reals+. If we were constructing,for example, a speech recognition system that could understand spoken directions and

    then automatically drive your car, we would want to characterize this set very carefully

    and thoroughly.

    (e) A reasonable choice for the domain is Naturals, since there is, in theory, no upper bound

    on the number of moves in a chess game. The range is a fairly large, but finite set.

    Each of the 64 squares on the board must be identified. Let them be {1, , 64} (nota particularly convenient naming, but adequate for our purposes). Next, each of the 32

    game pieces must be identified. Let them be {1, , 32}. Then a move can be given asa member of{1, , 64} {1, , 32}.

    9. (a)

    Population: Cities Naturalswhere Cities is the set of cities.

    (b) This problem is a little tricky, since it is possible for there to be two entries in the whitepages with the same name, and two entries with the same phone number. Thus, it will

    not work to map names into phone numbers, nor phone numbers into names. Instead,

    we choose the domain Naturals to represent the position of the white pages entry in the

    phone book, and the range to be Names {0, 1, , 9}7.(c)

    Birthdates: Students Dateswhere the sets are obvious.

    (d)

    Frequencies: Stations

    [530, 1700]

    where Stations = KDOG, and the frequencies are in units of kHz. Note that wecould actually be more specific and make the range a discrete set, since the FCC only

    allocates certain discrete frequencies.

    (e)

    Frequencies: Stations [88, 108]where Stations = KQED, KPFA, and the frequencies are in units of MHz. Note thatagain we could actually be more specific and make the range a discrete set, since the

    FCC only allocates certain discrete frequencies.

  • 8/2/2019 Solutions 020812

    14/248

    8 CHAPTER 1. SIGNALS

    10. The two plots are shown below:

    1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 13

    2

    1

    0

    1

    2

    3

    1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 11

    0.5

    0

    0.5

    1

    Notice that in the first case, the samples all have value 0. In the second case, the samples also

    do not accurately reflect the structure of the waveform. This is a clear indication that we have

    not sampled frequently enough. The Matlab commands that generated these plots are:

    denseTime = [-1:0.01:1];

    sampleTime = [-1:0.2:1];

    y1 = exp(-denseTime).*sin(10*pi*denseTime);

    y2 = exp(-sampleTime).*sin(10*pi*sampleTime);

    subplot(2,1,1), plot(denseTime,y1,-,sampleTime,y2,o);

    chirp1 = cos(10*pi*denseTime.2);chirp2 = cos(10*pi*sampleTime.2);

    subplot(2,1,2), plot(denseTime,chirp1,-,sampleTime,chirp2,o);

    11. Figure 1.2 gives a plot of the function : [0, 5] [, ]. Mathematically, for all t [0, 5],

    (t) = 2t mod 2,

    where for any , mod2 = is the number [, ) such that is a multiple of2. Although is a discontinuous function, the motion is continuous since the position of thependulum at time t is given by l cos (t) and l sin (t) which are continuous in t.

  • 8/2/2019 Solutions 020812

    15/248

    9

    t

    0 1 2 3 4 5

    l

    lsin

    lcos

    Figure 1.2: Plot of for problem 11

    12. (a) One way to give an element f [X Y] is to give a set of pairs (x, f(x)), one foreach x X. This way, we can define all the functions in [X Y]:

    {(a, 0), (b, 0), (c, 0)},

    {(a, 0), (b, 0), (c, 1)

    },

    {(a, 0), (b, 1), (c, 0)},{(a, 0), (b, 1), (c, 1)},{(a, 1), (b, 0), (c, 0)},{(a, 1), (b, 0), (c, 1)},{(a, 1), (b, 1), (c, 0)},{(a, 1), (b, 1), (c, 1)}.

    (b) For every element in X, there are n possible values in Y. Since there are m elementsin X, the total number of possible functions is nm. Note that this number grows to bevery large for even moderately small finite sets.

    (c)

    2566000 = 10b log10(a) 1014449.

  • 8/2/2019 Solutions 020812

    16/248

    10 CHAPTER 1. SIGNALS

  • 8/2/2019 Solutions 020812

    17/248

    Chapter 2

    Defining Signals and Systems Solutions

    1. With the given m and 20 Hz carrier frequency, for all t Time,

    AMSignal(t) = (1 + cos(t))sin(2 20t).

    This is plotted for Time = [0, 1] below:

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 12

    1.5

    1

    0.5

    0

    0.5

    1

    1.5

    2

    The Matlab commands to generate this plot are:

    t = 0:1/400:1;

    AMSignal = (1 + cos(pi * t)).*sin(2*pi*20*t);

    plot(t,AMSignal);

    2. (a) The functions are shown below:

    11

  • 8/2/2019 Solutions 020812

    18/248

    12 CHAPTER 2. DEFINING SIGNALS AND SYSTEMS SOLUTIONS

    f g (when t0= 1)g (when t0= -1)

    (b) If(t, y)

    graph(f) then f(t) = y. Hence g(t + t0

    ) = f((t + t0

    )

    t0

    ) = f(t) = y, so(t + t0, y) graph(g).

    (c) If a particular value y occurs for f at time t, then the same value y will occur for g attime t + t0. For t0 > 0 this is later in time, so it is reasonable to call this a delay.

    3. (a) false

    (b) false

    (c) false

    (d) false

    4. For the left graph,

    x [1, 1], f(x) =

    0, x [1, 0]2x, x (0, 0.5]2 2x, x (0.5, 1]

    For the right graph,

    x [1, 1], g(x) =

    1, x [1, 000, x = 00.5, x (0, 1]

    The graphs of the compositions are shown below:

    -1 0 1 -1 0 1

    -0.5

    graph(f o g) graph(g o f)

    5. (a) Yes, this is the graph of a function. The table is:

  • 8/2/2019 Solutions 020812

    19/248

    13

    x X y Ya 1b 1

    c 2

    (b) This is not the graph of a function because for a in the domain there are two possiblevalues in the range.

    (c) This is also not the graph of a function because it is incomplete. It does not give the

    value of the function for c in the domain.

    6. (a) Each entry in the table T is of the form (d, outputPort), where d D and outputPort{O1, O2}. Thus, the entry (d, outputPort) D{O1, O2}. Hence, T D{O1, O2}.

    (b) T should be the graph of a function because for each destination address there shouldbe listed exactly one output port, or else the router would not know what to do with the

    packet.

    (c) Let Packets = D otherData be the set of possible packets. The set otherData is theset of possible data, other than destination addresses, that the router carries. Define

    PacketStream:Naturals Packets.

    Then an input to the router is in PacketStream, and an output is in PacketStream2.

    (d) The switch is a function

    Switch:PacketStream

    PacketStream2

    such that if the input x PacketStream and Switch(x) = (y, z), then y is the substreamofx whose destination addresses satisfy T(d) = O1 and z is the substream ofx whosedestination addresses satisfy T(d) = O2.

    7. (a) assignment, assertion, predicate

    (b) assignment, assertion, predicate

    (c) assertion, predicate

    (d) assertion

    (e) assertion, predicate

    8. Recall from exercise 12 of the previous chapter that ifX has m elements and Y has n ele-ments then [X Y] has nm elements. In this case, the size of the domain is 2m instead ofm and the size of the range is 2n. Thus, the number of possible logic circuits is

    (2n)(2m).

    9. (a) The simplest example is the identity system:

    x, n, H(x)(n) = x(n).

  • 8/2/2019 Solutions 020812

    20/248

    14 CHAPTER 2. DEFINING SIGNALS AND SYSTEMS SOLUTIONS

    (b) A simple example is a system which converts negative values to 0 and positive values to

    1:x, n, H(x)(n) =

    0, ifx(n) 01, ifx(n) > 0

    (c) A simple example is a zero-order hold:

    x, t Reals, H(x)(t) = x(n), where n = t.

    10. (a)

    f g Nats Y Reals

    (b) sum(cos(2*pi*[1:100]/x))

    (c) 100.

    11. The following Matlab function can be defined in a file called movingAverage.m:

    function y = movingAverage(x)

    % MOVINGAVERAGE Four-point moving average.

    for n=1:3

    y(i) = sum(x(1:n))/4;

    end;

    N = 4:length(x);

    y(N) = (x(N-3) + x(N-2) + x(N-1) + x(N))/4;

    Notice the way this is written. The for loop calculates the first four samples. The last linecalculates all the remaining samples, exploiting the fact that Matlab automatically vectorizes.

    This yields a very compact definition. An even more compact definition is

    function y = movingAverage(x)

    % MOVINGAVERAGE Four-point moving average.

    z = [zeros(1,3), x];

    N = 1:length(x);

    y(N) = ( z(N) + z(N+1) + z(N+2) + z(N+3))/4;

    Here, we prepend 3 zeros in front of the argument vector, and then compute the output vector

    by adding five neighboring values of the expanded vector.

    (a) The unit step at 10 can be generated compactly with the commands:

    N = 1:20;

    x = N>=10;

    The second command assigns to each element of the vector x the result of comparing

    the corresponding value of t to 10. To check this, plot x with the command:

    stem(x)

    which yields:

  • 8/2/2019 Solutions 020812

    21/248

    15

    0 2 4 6 8 10 12 14 16 18 200

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    To apply the function we defined above, we need to make sure the m-file storing the

    function is available to Matlab. The simplest way to do this is to make the current

    directory in Matlab the same as the directory storing the m-file, e.g., assuming it is

    directory d:\users\eal,>> cd D:\users\eal

    >> pwd

    ans =

    D:\users\eal

    Then,

    stem(movingAverage(x))

    yields the following plot:

    0 2 4 6 8 10 12 14 16 18 200

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    (b) N = 1:20;

    x = N>=15;

    stem(movingAverage(x))

    yields the following plot:

  • 8/2/2019 Solutions 020812

    22/248

    16 CHAPTER 2. DEFINING SIGNALS AND SYSTEMS SOLUTIONS

    0 2 4 6 8 10 12 14 16 18 200

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    Note that is simply delayed by 5 samples, just like the input.

    (c) The alternating signal can be generated and the moving average applied by

    x = cos(pi * [0:19]);

    y = movingAverage(x);

    The result can be plotted together with the original using

    N = 1:20;

    plot(N,x,x:,N,y,o-)

    which yields the result

    0 2 4 6 8 10 12 14 16 18 201

    0.8

    0.6

    0.4

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    (Unfortunately, Matlab does not support stem plots with more than one signal, so we

    use the plot command.)

    (d) The moving average system changes abrupt transitions into more gradual transitions. In

    the case of the alternating input, because this signal consists of a repeated sequence of

    abrupt transitions, the size of the alternation is reduced to zero after the initial transient.

    The initial transient is due to the fact that the data prior to the first input is assumed to

    have value zero rather than to be alternating.

  • 8/2/2019 Solutions 020812

    23/248

    17

    12. Using the specified fact from calculus,

    (F(x))(t) =1

    10(cos((t 10)) cos(t)).

    From this, we can already see that the amplitude of the output decreases as increases be-cause the factor in parenthesis has magnitude no greater than two, and is in the denominatorof the factor on the left. We can apply the identity in the footnote with

    = 10 = 0

    A = 1

    B =

    1

    to get

    (F(x))(t) =R

    10cos(t + )

    where R and are (for fixed ) constants given by the identity. This is sinusoidal with thesame frequency as the input.

    13. (a) h:Reals Integers such that for all x Reals,

    h(x) =

    1 ifx > 10 ifx = 11 ifx < 1

    (b) Here is a block diagram:

    F G[Reals Reals ]

    [Reals Reals ]

    [Reals Integers]

    (c) The desired signal is u:Reals Integers where for all x Reals,

    u(x) = 0 ifx is an odd integer

    1 otherwise

    Note that this signal is 1 almost everywhere and goes to zero only a countable number

    of discrete points on the real line. No real-world signal would behave this way.

    14. H: D D such that for all x D and n Integers, H(x) satisfies

    (H(x))(n) = x(n) (H(x))(n 1).

    This is as much as we can define H. This definition is complete only if such H(x) exists andis unique.

  • 8/2/2019 Solutions 020812

    24/248

    18 CHAPTER 2. DEFINING SIGNALS AND SYSTEMS SOLUTIONS

    15. (a) Let y = H(x), as in the diagram, and note that y = 0.5(y + x/y). Multiplying through

    by y we get y2 = 0.5(y2 + x)

    which means that

    x = y2

    so

    y =

    x.

    (b) The following Matlab sequence shows the result for x = 4:

    > > x = 4 ;

    > > y = 1 ;

    >> y = 0.5*(y + x/y)

    y =

    2.5000

    >> y = 0.5*(y + x/y)

    y =

    2.0500

    >> y = 0.5*(y + x/y)

    y =

    2.0006

    >> y = 0.5*(y + x/y)

    y =

    2.0000

    >>

    The following Matlab sequence shows the result for x = 4:

    >> x = 12;

    >> y= 1;

    >> y = 0.5*(y + x/y)

    y =

  • 8/2/2019 Solutions 020812

    25/248

    19

    6.5000

    >> y = 0.5*(y + x/y)

    y =

    4.1731

    >> y = 0.5*(y + x/y)

    y =

    3.5243

    >> y = 0.5*(y + x/y)

    y =

    3.4646

    >> y = 0.5*(y + x/y)

    y =

    3.4641

    >> sqrt(12)

    ans =

    3.4641

    >>

  • 8/2/2019 Solutions 020812

    26/248

    20 CHAPTER 2. DEFINING SIGNALS AND SYSTEMS SOLUTIONS

  • 8/2/2019 Solutions 020812

    27/248

    Chapter 3

    State Machine Models Solutions

    1. (a) This state machine is not deterministic because if it is in state s and input a arrives, thenthere are two possible transitions to take.

    (b) The else arc is a self loop (both the source and destination states are s), and else ={c, absent}.

    2. (a) The state response is

    (idle, idle, idle, count1, idle, count1, count2,play greeting, idle, ).

    (b) The trace is

    idleoffhook idle offhook idle ring count1 offhook idle

    ring count1 ring count2 ring play greeting offhook idle

    (c) The output is

    (absent, absent, absent, absent, absent, absent, answer, absent, ).

    3. The solution is shown below:

    21

  • 8/2/2019 Solutions 020812

    28/248

    22 CHAPTER 3. STATE MACHINE MODELS SOLUTIONS

    0 1 11

    {1} / 0 {1} / 0

    {0} / 0

    {0} / 0

    {1} / 1{0} / 0

    0 1 11

    {1} / 0{1} / 0 {1} / 1{0} / 0

    10

    {1} / 1{0} / 0

    (a)

    (b)

    {0} / 0{0} / 0

    For part (a), States = {0, 1, 11} while for part (b), States = {0, 1, 11, 10}.4. (a) The state transition diagram for the mod-4 counter is shown in figure3.1.

    (b) The update table is:

    state next state/output under input

    increment decrement reset absent

    0 1/1 3/3 0/0 0/ absent

    1 2/2 0/0 0/0 1/ absent

    2 3/3 1/1 0/0 2/ absent

    3 0/0 2/2 0/0 3/ absent

    (c) The set of states is

    States = {0, 1, 2, 3}.The set of inputs is

    Inputs = {increment, decrement, reset, absent}.

  • 8/2/2019 Solutions 020812

    29/248

    23

    0 1 2

    {increment}/1

    {decrement,

    reset}/0

    3

    {reset, increment}/0

    {reset}/0

    {reset}/0

    {decrement}/1 {decrement}/2

    {increment}/2 {increment}/3

    {decrement}/3

    Figure 3.1: Solution to exercise 4.

    The set of outputs is

    Outputs = {0, 1, 2, 3, absent}.The update function

    update: States Inputs States Outputs

    is given by the table in part (b).

    (d) The state response for the input sequence increment4, decrement3,... is

    1, 2, 0, 1, 2, 1, 0, 2, .

    5. (a) The state machine is shown in figure3.2. The stuttering transitions are all implicit. The

    definition is:

    States =

    {a,b,c

    }Inputs = {a,b,c, absent}Outputs = {a,b,c, absent}

    initialState = a

    and (s, x) States Inputs,

    update(s, x) = (x, s).

    (b) The past history that needs to be summarized is only the previous input. But since the

    input set is infinite, then the number of patterns needed to summarize that past history is

  • 8/2/2019 Solutions 020812

    30/248

    24 CHAPTER 3. STATE MACHINE MODELS SOLUTIONS

    a b c

    {b}/a

    {a}/b

    {c}/b

    {c}/a

    {b}/b

    {b}/c

    {c}/c

    {a}/c

    {a}/a

    Figure 3.2: Solution to exercise 5(a).

    infinite. An infinite state machine for this instance ofUnitDelay is similar to the finite

    state machine in part (a), with the only differences being

    States = Naturals

    Inputs = {absent} Naturals0Outputs = {absent} Naturals0

    6. From the description ofEqual, it is clear that

    Inputs = {0, 1, absent},and

    Outputs = {equal, notEqual, absent}.We can define the state to be difference between the number of ones that have arrived and the

    number of zeros that have arrived, in which case,

    States = Integers.

    Then for all s States and x Inputs,

    update(s, x) =

    (0, equal) if(x = 1

    s =

    1)

    (x = 0

    s = 1)

    (s + 1, notEqual) ifx = 1 s = 1(s 1, notEqual) ifx = 0 s = 1(s, absent) otherwise

    7. When designing a FSM, first consider the general operation and possible complications for

    the machine, and define the possible inputs and outputs. Then, create the necessary states and

    state transitions. You also need to choose the level of detail at which you do the modeling. For

    this problem, for example, is there any point in modeling the position of the elevator between

    floors? Probably not. The solution given here is certainly not unique. There are many other

    equally valid designs.

  • 8/2/2019 Solutions 020812

    31/248

    25

    A controller for an elevator should manage the elevators basic movements. An elevator has

    three fundamental motions: move up (moveUp), move down (moveDown), and stop (stop).These three actions, plus the stuttering element, constitute the outputs for the FSM. Hence

    Outputs = {stop, moveUp, moveDown, absent}.

    Two of the inputs to the FSM are well defined as requests for service on floor one and floor

    two. These two inputs instruct the elevator to begin moving. Input is also needed to instruct

    the elevator to stop moving when it has arrived at floor. It is acceptable to assume that de-

    tectors exist at each floor to inform the FSM of the elevators position. With the stuttering

    element, the four possible inputs are

    Inputs =

    {reqOne, reqTwo, arrival, absent

    },

    which are a request for service to floor one, a request for service to floor two, and notification

    of arrival at a floor.

    Because all requests should be served, special cases exist if requests for service are received

    while the elevator is in motion. If a request for service is received for the destination floor,

    the request is redundant and can be safely ignored. If a request for service is received for

    the other floor, the request should be stored for later service. Subsequent requests for that

    floor are redundant and can be ignored, as well. So, for each floor there are three basic states:

    stopped on the floor (onOne, onTwo), moving to the floor (toOne, toTwo), and moving to the

    floor with a request for the other floor (toOneReqTwo, toTwoReqOne). Thus,

    States = {onOne, onTwo, toOne, toTwo, toOneReqTwo, toTwoReqOne}.

    With the operation of the elevator understood and the states, inputs, and outputs well defined,

    the definition of the state transition function is clear. For this FSM, a graph is the most

    intuitive representation for the state transitions:

    onOne toTwotoTwoReq

    One

    {reqTwo} /moveUp

    {reqOne}

    else elseelse

    onTwo toOnetoOneReq

    Two

    {reqOne} /moveDown

    {reqTwo}

    else else

    else

    {arrival}/

    stop

    {arrival}/

    moveDown

    {arrival}/

    stop

    {arrival}/

    moveUp

  • 8/2/2019 Solutions 020812

    32/248

    26 CHAPTER 3. STATE MACHINE MODELS SOLUTIONS

    8. The following machine does the job:

    0 1to3

    {1}/0

    {0}/1

    {0,1}/1

    As suggested by the state names, 1to3 matches states 1, 2, and 3, while 0 matches 0.

    9. (a) The possibleUpdates function is given by the following table:

    state next state/output under input

    0 1 absent

    A {(A, 0)} {(B, 1), (C, 0)} {(A, absent)}B {(B, 1)} {(B, 1)} {(B, absent)}C {(C, 0)} {(C, 0)} {(C, absent)}

    (b) One way to define this relation is as follows (ignoring suttering). Define the input signals

    zeros = (0, 0, )

    and

    xM = (0, , 0 M

    , 1, anything, )

    where M Naturals0. That is, xM is a sequence that starts with zero or more 0s (Mof them), followed by a 1, followed by any sequence of 0s and 1s. Note that since we

    are ignoring stuttering, all possible inputs have this form. Similarly, define

    yM = (0, , 0 M

    , 1, 1, )

    which is a sequence starting with zero or more 0s, followed by all 1s. Now we can

    define the relation

    Behaviors = {(xM, y) | (M Naturals0) (y = zeros y = yM)} {(zeros,zeros)}.

    10. The bisimulation relation is

    {(start, start), (1, 1), (11, 11), (110, 110), (start, 1100)}.

    11. (a) no

    (b) yes

  • 8/2/2019 Solutions 020812

    33/248

    27

    1

    0 0

    0

    0/r

    1

    00start

    1

    Figure 3.3: Machine which recognizes 000

    (c) no

    (d) yes

    (e) no

    12. A two-state bisimilar machine is shown below:

    a b

    {1} / 1

    {1} / 0

    The bisimulation relation is

    S = {(a, a), (b, b), (c, a), (d, b)},

    or equivalently,

    S = {(a, a), (b, b), (a, c), (b, d)},

    13. Yes, we can give such a machine B. It has one state; lets call it e, with two self loops labeled:

    Inputs/1

    Inputs/2

    The simulation relation is

    S = {(a, e), (b, e), (c, e), (d, e)}.

    14. We need to remember the patterns 1, 0, 00. The machine is given in figure3.3.

  • 8/2/2019 Solutions 020812

    34/248

    28 CHAPTER 3. STATE MACHINE MODELS SOLUTIONS

    15. (a)

    a

    {1}/1

    b c d

    ef

    {1}/0 {1}/0

    {1}/1

    {1}/0

    {1}/0

    (b)

    Behaviors = {(x, y) | x = (1, 1, 1, ) y = (1, 0, 0, 1, 0, 0, 1, 0, 0, )}.

    (c)

    ad

    {1}/1

    be cf

    {1}/0

    {1}/0

    The bisimulation relation is

    {(a,ad), (b,be), (c,cf), (d,ad), (e,be), (f,cf)}

  • 8/2/2019 Solutions 020812

    35/248

    Chapter 4

    Composing State Machines

    1. Assumptions about the component machines:

    OutputsA2 InputsB1

    Definition of the composite machine:

    States = StatesA StatesBInputs = InputsA InputsB2Outputs = OutputsA1 OutputsA2 OutputsBinitialState = (initialStateA, initialStateB)update((sA, sB), (xA, xB2)) = ((s

    A, s

    B), (yA1, yA2, yB))

    where (sA, (yA1, yA2)) = updateA(sA, xA)and (sB , yB) = updateB(sB , (yA2, xB2))

    2. (a) Assumptions about the component machines:

    OutputsA InputsB InputsCDefinition of the composite machine:

    States = StatesA StatesB StatesCInputs = InputsAOutputs = OutputsCinitialState = (initialStateA, initialStateB, initialStateC)update((sA, sB , sC), x) = ((s

    A, s

    B, s

    C), yC)

    where

    (sA, yA) = updateA(sA, x), (sB , yB) = updateB(sB , yA), and

    (sC, yC) = updateC(sC, yB).

    (b) For the first composition (A and B):

    Assumptions about the component machines:

    OutputsA InputsBDefinition of the composite machine:

    StatesD = StatesA StatesBInputsD = InputsA

    29

  • 8/2/2019 Solutions 020812

    36/248

    30 CHAPTER 4. COMPOSING STATE MACHINES

    OutputsD = OutputsB

    initialStateD = (initialStateA, initialStateB)updateD((sA, sB), x) = ((sA, s

    B), yB)

    where

    (sA, yA) = updateA(sA, x) and(sB , yB) = updateB(sB , yA).

    For the second composition (D and C):

    Assumptions about the component machines:

    OutputsD InputsCDefinition of the composite machine:

    States = StatesD StatesCInputs = InputsD

    Outputs = OutputsCinitialState = (initialStateD, initialStateC)update((sD, sC), x) = ((s

    D, s

    C), yC)

    where

    (sD, yD) = updateD(sD, x) and (sC, yC) = updateC(sC, yD).

    (c) The models in (a) and (b) are different but equivalent state machines.

    3. (a) Assuming the solution for UnitDelay,

    States = {a,b,c} {a,b,c}Inputs = {a,b,c, absent}

    Outputs ={

    a,b,c, absent}initialState = (a, a)

    and (s1, s2) States, x Inputs,

    update((s1, s2), x) =

    ((s1, s2), absent) ifx = absent((x, s1), s2) otherwise

    (b) Yes, all states are reachable.

    (c) For three machines:

    States = {a1, b1, c1} {a2, b2, c2} {a3, b3, c3}.To determine how many elements there are in this set, consider first the product ofthe first two. For each element of the set {a1, b1, c1} there are three elements of theset {a2, b2, c2}. Thus, this first product has 3 3 = 9 elements. For each of the 9elements of this set, there are three elements of the set {a3, b3, c3}, so the set States has3 3 3 = 27 elements.For four machines:

    States = {a1, b1, c1} {a2, b2, c2}{a3, b3, c3} {a4, b4, c4}.

    Following a similar argument to that above, this set has 34 = 81 elements.

  • 8/2/2019 Solutions 020812

    37/248

    31

    (d) The pattern in part (c) suggests the answer. For a cascade ofn delays, there are 3n states.

    4. The block diagram is shown below:

    TranslatorA

    tick >> increment{incrementt}

    ParkingMeter

    clock Mod30Counter{tick} TranslatorB

    0>> in25

    else >> absent

    {0,... 29}

    {in25, absent}

    PoliceOfficer{expired, 1, 2, ... , 60}

    Mod45Counter

    TranslatorC

    0 >> check

    else >> absent

    {0,... 44}

    {check, absent}

    {ticket, absent}

    The state machines are:

    x

    {tick}/increment

    x

    {0}/in25 else

    TranslatorA TranslatorB

    x

    {0}/checkelse

    TranslatorC

    x

    {(check, epired)}/ticket else

    PoliceOfficer

    The ParkingMetermachine is the same as the solution in the previous chapter, except that the

    input alphabet is factored. The two modulo N counters are identical to those in the previouschapter, except for the value ofN.

  • 8/2/2019 Solutions 020812

    38/248

    32 CHAPTER 4. COMPOSING STATE MACHINES

    5. (a) The update function is

    update(s, x) =

    (0,zero) ifs = 1 and x = decrement(3, absent) ifs = 0 and x = decrement(s 1, absent) ifs > 1 and x = decrement(0,zero) ifs = 3 and x = increment(s + 1, absent) ifs = 3 and x = increment(0,zero) ifx = reset(s, absent) ifx = absent

    A sketch is shown below:

    0 1

    {increment}/absent

    {decrement, reset}/zero

    2

    {increment}/absent

    3

    {decrement}/absent

    {decrement}/absent

    {reset}/zero

    {reset, increment}/zero

    {increment}/absent

    {decrement}/absent

    (b) A sketch is shown below:

  • 8/2/2019 Solutions 020812

    39/248

    33

    0 1

    {increment}/absent

    {decrement}/zero

    {increment}/increment

    {reset}/reset

    {decrement}/decrement

    {reset}/reset

    0 1

    {increment}/absent

    {decrement}/absent

    {increment}/zero

    {reset}/zero

    {decrement}/absent

    {reset, zero}/zero

    {increment, decrement, reset, absent}

    {increment, decrement, reset, zero, absent}

    {zero, absent}

    (c) The bisimulation relation is

    {(0, (0, 0)), (1, (1, 0)), (2, (0, 1)), (3, (1, 1))}.

    6. One possible design structures the state machines as follows:

  • 8/2/2019 Solutions 020812

    40/248

    34 CHAPTER 4. COMPOSING STATE MACHINES

    {button press, absent}

    {timeout, absent}TrafficLight

    {cross, wait, absent}

    WalkLight

    timer

    {start timer, absent}

    where the state transition diagram for the traffic light model is:

    yellow red

    extension

    requested

    {(*,timeout)}/

    (cross, start timer){(button press,*)}/

    (absent, start timer)

    {(button press, absent)}

    green

    {(absent, timeout})/

    (wait, absent)

    else

    else

    extended

    red

    {(*,timeout)}/(cross, start timer)

    else

    {(*,timeout)}/

    (wait, absent)

    else

    {(button press,timeout})

    and the state transition diagram for the wait light is:

  • 8/2/2019 Solutions 020812

    41/248

    35

    cross

    {wait}

    {cross }

    wait

    else

    else

    This assumes that the crossing light starts in the wait state and that outputs from this state

    machine change it.

    The set of states for the traffic light is

    States = {green,yellow, red, extension requested, extended red},

    The set of inputs is

    Inputs = {button press, absent} {timeout, absent}.

    The set of outputs is

    Outputs = {start timer, absent} {wait, cross, absent}.

    The WaitLightmachine is more trivial:

    States = {wait, cross},

    Inputs = {wait, cross, absent}.There are no outputs, so

    Outputs = {absent}.

    7. In each case, let i denote the size of the input alphabet of the composition, o the size of theoutput alphabet, and s the number of states.

    (a) i = iAiB , o = oAoB , and s = sAsB.

    (b) i = iA, o = oB , and s = sAsB .

    (c) i = 2, o = oA, and s = sAsB.

    8. This algorithm and its variants are used to verify properties such as all states are reachable.

    (a) By definition, ReachableStates(n + 1) is the union of some set and ReachableStates(n),so that certaintly ReachableStates(n) is a subset ofReachableStates(n + 1).

    (b) We first show by induction that ReachableStates(n) is the set of states reachable frominitalState in n or fewer steps. This is certainly true for n = 0, since by definition,ReachableStates(0) = {initialState}. Suppose the assertion is true for some n 0, andconsider the assertion for n + 1.

  • 8/2/2019 Solutions 020812

    42/248

    36 CHAPTER 4. COMPOSING STATE MACHINES

    Suppose s(n+1) ReachableStates(n+1). By definition, either s(n+1) ReachableStates(n)in which case s(n + 1) is reachable from initialState in n or fewer steps, or there existsa state s(n) ReachableStates(n) from which s(n + 1) can be reached in one step, sothat s(n + 1) can be reached from initialState in n + 1 or fewer steps.

    On the other hand ifs(n + 1) is reachable from initialState in n + 1 or fewer steps, thenthere is a sequence of state transitions

    initialState s(1) s(2) s(k) s(n + 1),

    with k n, in which case s(k) ReachableStates(n) so that, by definition, s(n + 1) ReachableStates(n + 1). The assertion now follows by induction.

    Now suppose

    ReachableStates(n) = ReachableStates(n + 1). (4.1)

    We show that

    ReachableStates(n + 1) = ReachableStates(n + 2).

    Suppose s(n + 1) ReachableStates(n + 2). Then either s(n + 1) is already inReachableStates(n+1), in which case we are done, or there is a state s(n) ReachableStates(n+1) from which s(n + 1) can be reached in one step. But, by hypothesis, s(n) is reach-able in n steps. It follows that s(n + 1) is reachable in n + 1 steps, i.e. it is inReachableStates(n+1). We can repeat the argument and show that ReachableStates(n) = = ReachableStates(n + k).

    (c) If (4.1) holds for n = N, then

    ReachableStates(N) = ReachableStates(N + k),

    for all k. So if a state s(n) is reachable in any number of steps, it is reachable in at mostN steps, hence ReachableStates(N) is the set of all reachable states.

    (d) Suppose a state s(n) is reachable in N + k steps but not in fewer steps for some k 0.So there is a sequence of transitions,

    initialState = s(0) s(1) s(N + k) = s(n).

    But since there are N states in all, it must be the case that s(i) = s(j) for some 0 i = 0. We need to show that it is true for n + 1. Todo this, note that

    An+1 = AnA =

    an nan1

    0 an

    a 10 a

    =

    an+1 nan + an

    0 an+1

    ,

    which agrees with the hypothesized result with n replaced by n + 1.

    3. The composition f f is given by

    x RealsN, f f(x) = A2x.

    It is also linear.

    41

  • 8/2/2019 Solutions 020812

    48/248

    42 CHAPTER 5. LINEAR SYSTEMS

    4. In (5.27) we substitute n = 32, a = 1.015b = 1, s(0) = 10000, s(32) = 0 and x(0) = = x(31) = w to get

    0 = 1.01532 10000 +31

    m=0

    1.01531mw,

    from which

    w = 0.015 10000 1.01532

    1.01532 1 = 395.7.The total payment over 32 months is 395.7 32 = 12665.

    5.

    A = 0 10 0 , b =

    01 , c =

    11 , d = 0.

    6. (a)

    s(0) =

    10

    s(1) =

    1 10 1

    10

    =

    10

    Since the state does not change, we can conclude it will never change while the input is

    zero, so for all n Integers,s(n) = 10 .

    (b)

    s(0) =

    01

    s(1) =

    1 10 1

    01

    =

    11

    s(2) =

    1 10 1

    11

    =

    21

    s(3) = 1 10 1 21 = 31 We conclude that for all n Integers,

    s(n) =

    n1

    .

    (c) Following the same tactic as in (b), we conclude that for all n Integers,

    s(n) =

    n + 1

    1

    .

  • 8/2/2019 Solutions 020812

    49/248

    43

    7. We can writes(1) = a + x(0)s(2) = a + x(0) + x(1)s(3) = a + x(0) + x(1) + x(2).

    Since y(3) = s(3), to get y(3) = 0 we need

    a + x(0) + x(1) + x(2) = 0.

    With the three samples ofx constrained to be equal to a constant b, then obviously b = a/3.8. Since s(0) = [0, 0]T,

    s(1) = As(0) + bx(0) = [0, x(0)]T.

    and

    s(2) = As(1) + bx(1) = [x(0), x(1)]T.

    Thus, we need x(0) = 1 and x(1) = 2.

    9. (a)

    A =

    0 10 0

    , b =

    01

    , c =

    1/31/3

    , d = 1/3.

    (b)

    A =

    1/2 1/2

    1/2

    1/2

    , b =

    11

    , c =

    1/3

    0

    , d = 1/3.

    10. (a) If = 0, then the state will always be zero after the first reaction, so for all n Naturals,

    s(n) = [ c 00] .

    (b) The following Matlab script sets things up:

    >> sigma = 0.9;

    >> A = [cos(pi/6), sin(pi/6); -sin(pi/6), cos(pi/6)]

    A =

    0.8660 0.5000

    -0.5000 0.8660

    >> s(:,1) = [1;0]

    s =

    1

    0

  • 8/2/2019 Solutions 020812

    50/248

    44 CHAPTER 5. LINEAR SYSTEMS

    Notice the syntax of the last command. The colon says that all rows of the first column

    are being defined. This first column will represent the initial state s(0). Unfortunately,Matlab arrays are indexed starting with 1, not 0, so we have to mentally do the transla-tion. We can calculate the state s(1) and store it in the second column as follows:

    >> s(:,2) = A*s(:,1)

    s =

    1.0000 0.8660

    0 -0.5000

    We can calculate the states s(2), , s(12) as follows:

    >> for i=3:13

    s(:,i) = A*s(:,i-1);

    end

    >> s

    s =

    Columns 1 through 7

    1.0000 0.8660 0.5000 0.0000 -0.5000 -0.8660 -1.0000

    0 -0.5000 -0.8660 -1.0000 -0.8660 -0.5000 -0.0000

    Columns 8 through 13

    -0.8660 -0.5000 -0.0000 0.5000 0.8660 1.0000

    0.5000 0.8660 1.0000 0.8660 0.5000 0.0000

    We can plot the first and second elements ofs(n) versus n as follows:

    >> plot(s)

    getting

  • 8/2/2019 Solutions 020812

    51/248

    45

    0 2 4 6 8 10 12 141

    0.8

    0.6

    0.4

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Note that the system behaves as an oscillator.

    11. (a) Here we may use the computational steps given in the text. The only difference is that

    Matlab arrays are indexed starting with 1 rather than zero. Define z(i) = s(i 1), andcalculate as follows:

    z(1) = 100;

    z(2) = 1.01*z(1) + 1000;

    for i=2:31

    z(i+1) = 1.01*z(i) - 30;

    end

    The plot is:

    0 5 10 15 20 25 30 350

    200

    400

    600

    800

    1000

    1200

    (b) From part (a) we find that the balance on day 31 is given by s(32) = 440.4349. We may

  • 8/2/2019 Solutions 020812

    52/248

    46 CHAPTER 5. LINEAR SYSTEMS

    also find this result in closed form using the supplied identity:

    s(31) = (1.01)31100 + 30m=0(1.01)30mx(m)= (1.01)31100 + (1.01)301000 30m=1(1.01)30m30= (1.01)31100 + (1.01)301000 30(1.01)30 30m=1(1.01)m= (1.01)31100 + (1.01)301000 30(1.01)30

    1(1.01)31

    11.01 1

    = 440.4349

    12. The impulse response is given by

    h(n) =

    d, ifn = 0

    can1b, ifn 1 .

    The impulse response for a = 1.1, a = 1.0, a = 0.9 and a = 0.5, where in all casesb = c = 1 and d = 0, is shown below:

    0 5 10 15 20 250

    1

    2

    3

    4

    5

    6

    7

    n

    h(n)fora=

    1.1

    0 5 10 15 20 250

    0.2

    0.4

    0.6

    0.8

    1

    n

    h(n)fora=

    1.0

    0 5 10 15 20 250

    0.2

    0.4

    0.6

    0.8

    1

    n

    h(n)fora=

    0.9

    0 5 10 15 20 250.5

    0

    0.5

    1

    n

    h(n)fora=

    0.5

    13. For n = 0 (5.37) givess(0) = A0initialState = initialState ,

    which is correct (note: A0 = I, the identity matrix). Now suppose the right-hand side of(5.37) gives the correct value ofs(n) for some n 0. From (5.33),

    s(n + 1) = As(n) + bx(n)

    = A{AninitialState +n1m=0

    An1mbx(m)} + bx(n)

  • 8/2/2019 Solutions 020812

    53/248

    47

    = An+1initialState +n

    m=1 Anmbx(m),

    which is the expression on the right-hand side of (5.37) for n + 1. It follows by inductionthat (5.37) is the correct expression for the state response s(n) for all n 0. The fact that theoutput response is given by (5.37) now follows by substituting (5.37) in (5.34).

    14. We want to show that for all n = 0, 1, 2, . . .

    An =

    cos(n) sin(n)sin(n) cos(n)

    .

    We may do so by induction. For n = 0:

    A0 = cos0 sin0

    sin 0 cos 0

    = 1 0

    0 1

    as required. Thus, the assertion is true for n = 0. Now, suppose the assertion is true forn = k. Then, for k + 1:

    Ak+1 = AkA

    =

    cos(k)cos() sin(k)sin() cos(k)sin() sin(k) cos()sin(k)cos() + cos(k)sin() sin(k)sin() + cos(k) cos()

    =

    cos((k + 1)) sin((k + 1))sin((k + 1)) cos((k + 1))

    .

    where the last equality follows from the given identities. This concludes the proof and theassertion is true for all n = 0, 1, 2, . . ..

    15. (a) The zero-input state response is given by:

    szeroinput(n) = An initialState

    =

    n cos(n) n sin(n)n sin(n) n cos(n)

    01

    =

    n sin(n)n cos(n)

    and the zero-input response is given by:

    yzeroinput(n) = cT An initialState

    =

    1 0 n sin(n)

    n cos(n)

    = n sin(n).

    (b) The zero-state impulse response is given by:

    h(n) =

    d, ifn = 0

    cTAn1b, ifn 1 .

  • 8/2/2019 Solutions 020812

    54/248

    48 CHAPTER 5. LINEAR SYSTEMS

    For the values ofA,b,c in this problem we obtain:

    h(n) =

    0, ifn = 0

    n sin((n 1)), ifn 1 .

    16. (a) A suitable model is:

    A =

    0 0 0 1 0 0 0 00 1 0 0 00 0 1 0 00 0 0 1 0

    , B =

    10000

    ,

    C = 0 0 0 , D = 1 ,(b) The only items in the state-space representation that change are B and D, which become

    B =

    0.5 0.50 00 00 00 0

    D = [0.5 0.5].

  • 8/2/2019 Solutions 020812

    55/248

    Chapter 6

    Hybrid Systems Solutions

    1. The following hybrid system will do the job:

    4 3

    AutomaticLoudnessCompensation

    x

    y

    v 1 2v2

    v1

    v2

    v2v1

    v1

    v4

    v4

    v4

    v3

    v3

    v3

    s(n+1) = As(n) + bx(n)y(n) = c

    1s(n) + dx(n)T

    s(n+1) = As(n) + bx(n)y(n) = c

    2s(n) + dx(n)T

    s(n+1) = As(n) + bx(n)y(n) = c3s(n) + dx(n)

    Ts(n+1) = As(n) + bx(n)y(n) = c4s(n) + dx(n)

    T

    The inputs are two discrete-time signals, v representing the current volume setting, and xrepresenting the audio signal. Each state i has a refinement that defines the state update and

    49

  • 8/2/2019 Solutions 020812

    56/248

    50 CHAPTER 6. HYBRID SYSTEMS SOLUTIONS

    output as

    n Integers, s(n + 1) = As(n) + bx(n)y(n) = cTs(n) + dx(n).

    The guard on each transition into state i is a set vi Inputs given byvi = {(v(n), x(n), s(n), y(n)) | Ti1 v(n) < Ti+1},

    where T0, , T5 are thresholds governing the levels where the filtering switches. T0 = 0 isthe lowest level and T5 = is the highest.

    2. The following hybrid system will do the job:

    1 2

    s(t) = 1 s(t) = 1

    AltTickGenerator

    4 3

    s(t) = 1 s(t) = 1. .

    . .

    v(t) {tick, absent}

    {s(t) | s(t)== 2}/ticks(t) := 0 {s(t) | s(t)== 1}/tick

    s(t) := 0

    {s(t) | s(t)== 1}/ticks(t) := 0

    {s(t) | s(t)== 1}/ticks(t) := 0

    Notice that all states have the same refinement, and that all transitions except the one into

    mode 1 have the same guard. The transition into mode 1 results in a delay of two units before

    the production of a tickevent.

    3. (a) The system generates an event sequence

    (0, 1, 3, 4, 6, 7, 9, 10, )

  • 8/2/2019 Solutions 020812

    57/248

    51

    at times

    0, 1, 3, 4, 6, 7, 9, 10, .

    That is, the value of each output event is equal to the time at which it is produced, and

    the intervals between events alternate between one and two seconds. Precisely,

    y(t) =

    t ift = 3k for some k Naturals0t ift = 3k + 1 for some k Naturals0absent otherwise

    (b)

    b/s(t)

    r(t) := 0

    two

    a/s(t)r(t) := 0

    y(t) Integers

    {absent

    }u(t) {reset, absent}

    c/absents(t) := 0r(t) := 0

    c ={(r(t), s(t), u(t)) | u(t) = reset}

    b ={(r(t), s(t), u(t)) | r(t) = 2 u(t) = absent}

    a ={(r(t), s(t), u(t)) | r(t) = 1 u(t) = absent}

    s(t) = 1

    r(t) = 1

    .

    .

    s(t) = 1

    r(t) = 1

    .

    .

    s(0) := 0

    r(0) := 0

    onec/absents(t) := 0r(t) := 0

    4. Assume the input alphabet is {ring, absent} and the output alphabet is {on, off, absent}. Thenthe following timed automaton will control the source of the tone:

  • 8/2/2019 Solutions 020812

    58/248

    52 CHAPTER 6. HYBRID SYSTEMS SOLUTIONS

    silent 3tone 3

    g1/ons(t) := 0

    silent 1 tone 1

    toneController

    .

    v(t) {on, off, a

    c(t) {ring, absent}silent 2

    tone 2

    g2/offs(t) := 0

    g3/ons(t) := 0

    g3/ons(t) := 0

    g2/offs(t) := 0

    g2/offs(t) := 0

    All states except silent 1 have as a refinement the system given by

    s(t) = 1.

    The guards are given by

    g1 = {(c(t), s(t)) | c(t) = ring}g2 = {(c(t), s(t)) | s(t) = 20}g3 = {(c(t), s(t)) | s(t) = 10}.

    This system ignores a ring input event that occurs less than 80 ms after the previous ring

    event.

    5. (a) Assume that the automobile provides the input open when the first door is opened and

    closedwhen the last open door is closed. The following machine provides on to turn on

    the dome light and off to turn it off:

    g1

    /on

    mode 1 mode 2

    domeLightController

    s(t) = 1.

    y(t) {on, off, absent}x(t) {open, closed, absent}

    g3/off

    mode 3

    g2

    g1

  • 8/2/2019 Solutions 020812

    59/248

    53

    The guards are given by

    g1 = {(x(t), s(t)) | x(t) = open}g2 = {(x(t), s(t)) | x(t) = closed}g3 = {(x(t), s(t)) | s(t) = 30}.

    Such sensors can be easily implemented as a daisy chain, a series connection of switches

    so that if any door is open, the electrical circuit is open.

    (b) Assume that the vehicle sensors provide the following input alphabet,

    Inputs = {warn, noWarn, absent},

    as suggested in the hint. The following model provides the requisite control:

    g1/ (beep, light)s(t) := 0

    quiet beeping

    seatbeltController

    s(t) = 1.

    {beep, off, ab

    x(t) {warn, noWarn, absent}

    g3/ (off, light)

    light

    g2/ (off, off)

    g2/ (off, off){light, off, ab

    g1/(beep, light)

    s(t):=0

    The guards are given by

    g1 = {(x(t), s(t)) | x(t) = warn}g2 = {(x(t), s(t)) | x(t) = noWarn}g3 = {(x(t), s(t)) | s(t) = 30 x(t) = absent}.

    6. The following hybrid system will do the job:

  • 8/2/2019 Solutions 020812

    60/248

    54 CHAPTER 6. HYBRID SYSTEMS SOLUTIONS

    1 2

    s(t) = 1 s(t) = 1

    Thermostat

    4 3

    s(t) = 1 s(t) = 1. .

    . .

    a(t) Reals {absent}{s(t)| s(t) = T

    4

    }/a4s(t) := 0 {s(t)| s(t) = T2}/a2

    {s(t)| s(t) = T1}/a1

    {s(t)| s(t) = T3}/a3

    You need four modes and one timer.

    7. The hybrid system is almost identical, with just 60 replaced with 30:

  • 8/2/2019 Solutions 020812

    61/248

    55

    nickel/absents(t) := 5

    expired safe

    s(t) = 0

    parkingMeter

    timeout={(u(t), s(t)) | u(t) = absentand s(t)= 0}

    .s(t) = 1.

    v(t) {expired,

    absent}

    s(0) := 0

    u(t) {coin5,

    coin25, absent}

    quarter/absents(t) := 25

    nickel/absents(t) := min(s(t) + 5, 30)

    quarter/absents(t) := min(s(t) + 25, 30)

    timeout/expired

    nickel ={(u(t), s(t)) | u(t) = coin5}

    quarter={(u(t), s(t)) | u(t) = coin25}

    The required state trajectory is shown below:

    mode(t)

    t...(a)

    (b)

    s(t)

    t...

    0 3 30

    expired

    safe

    8. The answer is no. The behavior cannot be reproduced by a finite state machine. The input

    symbols to the machine are in the alphabet {coin5, coin25, absent}. At each reaction, one ofthese inputs must be presented. If the stuttering input, absent, is presented, then the machine

    must stutter, and the output must be absent. But then the only other two possible inputs are

    coin5 and coin25. Neither of these will result in output expiredin the parking meter, so a state

    machine with these inputs and outputs would never produce the output symbol expired.

  • 8/2/2019 Solutions 020812

    62/248

    56 CHAPTER 6. HYBRID SYSTEMS SOLUTIONS

    9. The hybrid system is described below. Time t is in seconds. Four modes are needed corre-

    sponding to the four possible light configurations.

    g2 /YRs(t) := 0

    GR YR

    s(t) =1

    Intersection

    ..

    v(t) {GR, ..., RR}

    s(0) := 0

    u(t) {vehicle, absent}

    s(t) = 1.

    s(t) = 1..

    s(t) = 1..

    RG RY

    g1 /RGs(t) := 0

    g1 /YRs(t) := 0

    g3/YRs(t):=0

    g1 /GRs(t) := 0

    The guards are given by

    g1 = {(u(t), s(t)) | s(t) = 20}g2 =

    {(u(t), s(t))

    |s(t) = 240

    u(t)

    = vehicle

    }g3 = {(u(t), s(t)) | u(t) = vehicle}.

    10. The receiver protocol is a one-state finite state machine with one input from its NIC and two

    outputs: if a packet is received it is forwarded to the receiver application program, and at the

    same time an ackpacket is sent to the sender. The machine is shown below.

    wait

    SenderProtocol

    {packet}/(packet, ack)

    {packet, absent}

    {ack, absent}

    {packet, absent}

    There is a bug in this protocol. Suppose the sender sends a packet which is correctly re-

    ceived. The ReceiverProtocol forwards the packet to the receiver application and sends an

    ack. Suppose the ackarrives afterthe senders timer expires, in which case it will retransmit

    the same packet, and suppose this duplicate packet is also received. In that case the duplicate

    will be forwarded to the receiver, which would be wrong. To prevent forwarding duplicates,

    in internet protocols, the sender also attaches a unique sequence number to each packet. The

    ReceiverProtocol can now keep track of this sequence number and discard duplicate packets.

  • 8/2/2019 Solutions 020812

    63/248

    57

    11. (a) Suppose v(n) is the velocity just before the nth bounce. Then v(n +1) = av(n) and so

    v(n) = an1

    v(1).(b) The time tn tn1 is the time taken by the ball to return to the ground, starting at

    velocity v(n). So tn tn1 = 2v(n)/g.(c) The maximum height reached after the (n 1)st bounce is 12 (v(n))

    2

    g .

    12. (a) We need to write

    y1(t) = k1(p1 y1(t))/m1 (6.1)y2(t) = k2(p2 y2(t))/m2. (6.2)

    as

    s(t) = g(s(t)) (6.3)

    where

    s(t) =

    y1(t)y1(t)y2(t)y2(t)

    .

    Here is one way to write this:

    s(t) =

    y1(t)y1(t)

    y2(t)y2(t)

    =

    0 1 0 0

    k1/m1 0 0 0

    0 0 0 10 0 k2/m2 0

    y1(t)y1(t)

    y2(t)y2(t)

    +

    0k1p1/m1

    0k2p2/m2

    .

    Because of the non-zero added term on the end, the function g is not linear.

    (b) We need to write

    y(t) = gas

    s(t) = f(s(t))

    where

    s(t) = y(t)y(t) .Here is one way to write this:

    s(t) =

    y(t)y(t)

    =

    0 10 0

    y(t)y(t)

    +

    0

    g

    .

    Because of the non-zero added term on the end, the function f is not linear.

    13. The model is shown below

  • 8/2/2019 Solutions 020812

    64/248

    58 CHAPTER 6. HYBRID SYSTEMS SOLUTIONS

    {y1(t)==y2(t)}/

    y(t) :=y1(t)

    y(t) := (y1(t)m1 +y2(t)m2)/(m1+ m2)

    s(t) = b

    apart together

    y1(t) = k1(p1y1(t))/m1

    stickyMasses

    {(k1 k2)y(t) + k2p2k1p1> s(t)}/

    y1(t) :=y(t)

    y2(t) :=y(t)

    y1(t) :=y(t)y2(t) :=y(t)

    ..

    y1(t) Reals

    y2(t) Reals

    y1(0) :=initialPosition1y2(0) :=initialPosition2

    y1(0) := 0

    y2(0) := 0

    y2(t) = k2(p2y2(t))/m2..

    y(t) =.. k1p1 + k2p2 (k1+ k2)y(t)

    m1+ m2

    .

    .

    .

    .

    .

    .

    .

    . .

    s(t) = as(t).

    14. In leftmode, the refinement state evolves according to

    x(t) = 10 cos (t)

    y(t) = 10 sin (t)

    (t) =

    Intuitively this suggests that the vehicle moves in a circle with speed 10 mph. By integrating

    these differential equations we get

    x(t) x(0) =t0

    cos((0) + t)dt =10

    sin((0) + t)

    y(t) y(0) =t0

    sin((0) + t)dt = 10

    cos((0) + t)

    (t) (0) = tSo (x(t) x(0))2 + (y(t) y(0))2 = 1022 , which means the vehicle is moving in a circle ofradius 10/, and it takes 2 seconds to complete a circle.

    15. We call the hybrid system AGV,

    AGV= (States,Inputs, Outputs, TransitionStructure, initialState),

    where

    States = Modes RefinementStatesModes = {stop, right, straight, left}

    RefinementStates = Reals3 = {s = (x,y,) | x,y , Reals}Inputs = InputEvents = {stop, right, straight, left, absent},

    Outputs = OutputEvents = {absent}initialState = (stop, x0, y0, 0)

  • 8/2/2019 Solutions 020812

    65/248

    59

    AGVhas no time-based inputs or outputs. We now describe the TransitionStructure for two

    modes, stop and right, the others are similar. Call u(t) the input and e(t) the displacement attime t. (e(t) is a function of the refinement state (x(t), y(t), (t)).)

    If state at t is (stop, s(t)) and

    if guard {u(t) = straight} is true, then state at t+ is (straight, s(t))if guard {u(t) = right} is true, then state at t+ is (right, s(t))

    if guard {u(t) = left} is true, then state at t+ is (left, s(t))

    else ifTstop is the set of times t when the mode is stop, then t Tstop,

    x(t) = 0

    y(t) = 0(t) = 0

    If state at t is (right, s(t)) and

    if guard {|e(t)| < 1} is true, then state at t+ is (straight, s(t))if guard {0 > 2 > e(t)} is true, then state at t+ is (left, s(t))

    if guard {u(t) = stop} is true, then state at t+ is (stop, s(t))

    else ifTrightis the set of times t when the mode is right, then t Tright,

    x(t) = 10 cos (t)

    y(t) = 10 sin (t)

    (t) =

  • 8/2/2019 Solutions 020812

    66/248

    60 CHAPTER 6. HYBRID SYSTEMS SOLUTIONS

  • 8/2/2019 Solutions 020812

    67/248

    Chapter 7

    Frequency Domain Solutions

    1. (a) A finite discrete-time signal is a signal whose domain is a some finite subset

    [a, b] Integers,where a, b Integers and a < b. A discrete-time signal y:Integers Reals is periodicwith period p Integers if

    n Integers, y(n) = y(n +p).As a consequence, y(n) = y(n + kp), for all integers k.

    (b) A finite image is a signal whose domain is a subset

    [a, b] [c, d] Reals Realsfor some finite a,b,c,d where a < b and c < d. A periodic image will have to have aninfinite domain. The signal

    Image:Reals Reals Intensityis periodic with horizontal period ph Reals and vertical period pv Reals if

    x, y Reals, Image(x, y) = Image(x +ph, y) = Image(x, y +pv).

    As a consequence,

    Image(x, y) = Image(x + kph, y + mpv)

    for all integers k, m.

    2. (a)

    t Reals, x(t) = 10 sin(2t) + (10 + 2i)cos(2t)This function is periodic with a period of 1, since both components are periodic with

    that period.

    61

  • 8/2/2019 Solutions 020812

    68/248

    62 CHAPTER 7. FREQUENCY DOMAIN SOLUTIONS

    (b) The signal x is the sum of two periodic signals, say x1 with period p1 (fundamental

    frequency f1 = 1/p1), and x2 with period p2 (fundamental frequency f2 = 1/p2). So xis periodic with period p if and only if there are positive integers k1 and k2 such that

    p = k1p1 = k2p2.

    The period ofx is therefore the smallest p for which this relation holds. Note that if therelation holds, then

    p1/p2 = f2/f1 = k2/k1,

    which must be rational since k1 and k2 are both integers. Thus x given by

    t Reals, x(t) = sin(2t) + sin(

    2t)

    is not periodic since f1 = 1, and f2 =2/2 are not rationally related.

    (c) Using the same technique as in (b), the function x given by

    t Reals, x(t) = sin(2

    2t) + sin(

    2t)

    is periodic. Here f1 =

    2 and f2 =

    2/2. Let k1 = 2, k2 = 1, and f =

    2/2 =1/

    2. Therefore the signal is periodic with a period of1/f = 1.414.

    3. (a) The period is p = 9, or any integer multiple of 9.

    (b) With p = 9, the fundamental frequency is f0 = 1/9 cycles/sample, or 0 = 2/9

    radians/sample.(c) With p = 9 we get A0 = A2 = 1, while all other Ai are 0. 2 = 0, and all other i are

    arbitrary.

    4. (a) p = 2.

    (b) 0 = radians/second.

    (c) A2 = A3 = 1, Ak = 0, k / {2, 3}, and k = 0, k Naturals.

    5. The fundamental frequency is the largest f0 such that for each i, fi = kif0 for some integerki , where fi is the frequency of the i-th component.

    In this case, f1 = 440 Hz, f2 = 554 Hz, and f3 = 659 Hz. Notice that f3 is a prime numberand that f1 and f2 are integers. Therefore, the largest f0 that divides f1, f2, and f3 intointegers is 1 Hz. That is, the fundamental frequency is 1 Hz.

    Since sin(x) = cos(x /2), by inspection, the Fourier series coefficients are

    A440 = 1, 440 = /2A554 = 1, 554 = /2A659 = 1, 659 = /2

    All other coefficients Ak, k are 0.

  • 8/2/2019 Solutions 020812

    69/248

    63

    6. Observe that

    cos(0t + ) = Re{ej0t+

    } = Re{ej0t

    ej

    }.Writing each term on the left and right side of the equation in this form and factoring we

    determine that

    ARe{ej0tej} = 5Re{ej0t(ej/2 + ej/6 + ej2/3)}.We can calculate the sum of the three exponentials using Matlab:

    >> s = exp(j*pi/2) + exp(-j*pi/6) + exp(-j*2*pi/3)

    s =

    0.3660 - 0.3660i

    >> angle(s)

    ans =

    -0.7854

    >> abs(s)*5

    ans =

    2.5882

    Hence, A = 2.5882 and = 0.7854 = /4.7. (a) A radio wave travels at the speed of light, c m/s. Furthermore, as it travels, the wave

    gets attenuated (because its power spreads in three dimensional space). So ifx is thetransmitted radio wave, the radio wave received at a distance l meters away at time twill be y(t) = ax(t l/c), where a is the attenuation (a < 1).

    (b) If there were 10 reflected paths (one direct, 9 reflected), the received signal would be

    t

    Reals,

    y(t) = A9

    k=0

    k cos(2f(t lk/c))

    where lk is the length of the k-th path and is the attenuation along that path.

    (c) The phase shift along the k-th path is

    k = 2f lk/c,

    which has units of radians. Notice that the wavelength is = c/f, so

    k = 2lk/,

  • 8/2/2019 Solutions 020812

    70/248

    64 CHAPTER 7. FREQUENCY DOMAIN SOLUTIONS

    (d) Since k 0 = 2f(lk l0), = 2Lf/c.

    (e) In this case,

    y(t) = A0 cos(2f t 0) + A1 cos(2f t 0 ).

    Note that in general cos( ) = cos(), so

    y(t) = A cos(2f t 0)(0 1).

    So the amplitude of the direct signal is reduced by the full amount of the amplitude of

    the reflected signal. The reflected signal is said to be 180 degrees out of phase.

    (f) Using the result of (d), to get /10 we need

    2Lf/c /10.

    Since L 500, we need to constrain f so that

    2 500f /c 1/10.

    Using c = 3 108, we needf 3 104.

    So if we can use a radio frequency below 30 kHz, then we are assured of not having

    much destructive interference. Unfortunately, there is not much bandwidth below 30

    kHz, and it is impractical to build mobile radios at these frequencies anyway because of

    the huge antennas that are required. Thus, mobile radio systems have to contend with

    destructive multipath interference.

    (g) A frequency interferes destructively if

    1 0 = 2fL/c = (2n + 1).

    for some integer n. I.e.,

    L = (2n + 1)c/2f = (2n + 1)/2.

    Thus, we get destructive interference if L equals an odd multiple of half the wavelength.

    8. (a) For any t Reals,

    y(t +p) =

    k=

    x(t +p kp) =

    m=

    x(t mp) = y(t),

    by change of variables, m = k 1. Hence, y is periodic with period p.(b) With p = 1, the graph ofy looks like this:

  • 8/2/2019 Solutions 020812

    71/248

    65

    0 0.4 1

    (c) With p = 2, the graph ofy looks like this:

    0 0.4 1

    (d) With p = 0.8, the graph ofy looks like this:

    0 0.4 1

    (e) With p = 0.5, the graph ofy looks like this:

    0 0.4 1

    (f) In this case,

    w(t) = y(t + 4).

    With p = 1, the graph ofw looks like this:

    0 0.6 1

    9. (a) We need to show that for all t Reals, y(t) = y(t +p). But this is true, sincey(t +p) = f(x(t +p)) = f(x(t)) = y(t)

  • 8/2/2019 Solutions 020812

    72/248

    66 CHAPTER 7. FREQUENCY DOMAIN SOLUTIONS

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

    1

    0.8

    0.6

    0.4

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Figure 7.1: Solution to (b) of problem 9.

    since x is periodic with period p.

    (b) The plot over one period is shown in figure 7.1. It was generated using the following

    Matlab code:

    t = [0:1/200:1];x = sin(2*pi*t);

    y = sign(x);

    plot(t,x,-,t,y,.);

    (c) The plot over one period ofx is shown in figure7.2. It was generated using the followingMatlab code:

    t = [0:1/200:1];

    x = sin(2*pi*t);

    y = x.*x;

    plot(t,x,-,t,y,.);

    10. Denote the square wave by sp:Reals Reals. Assume the periodic image is a functionImage:Reals Reals Reals

    given by (x, y) Reals Reals,Image(x, y) = sh(x)sv(y).

    Thus, given that

    sp(t) = A0 +k=1

    Ak cos(2kt/p + k)

  • 8/2/2019 Solutions 020812

    73/248

    67

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 11

    0.8

    0.6

    0.4

    0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

    Figure 7.2: Solution to (c) of problem 9.

    we have

    Image(x, y) = [A0 +

    k=1Ak cos(2kx/p + k)][A0 +

    k=1Ak cos(2ky/p + k)].

    If we let 0 = 0 and change variables on the second summation, this can be written

    Image(x, y) = [k=0

    Ak cos(2kx/p + k)][

    m=0

    Am cos(2my/p + m)].

    Multiplying out the summations yields

    Image(x, y) =k=0

    m=0

    AkAm cos(2kx/p + k) cos(2my/p + m),

    from which we recognize that the Fourier series coefficients for the image are

    Ak,m = AkAm,

    with phases k and m = m.

    11. Evaluating both sides at t = 0, it follows immediately that

    A1 = A2.

    Taking derivatives on both sides, we get that

    t Reals i1A1ei1t = i2A2ei2t.

  • 8/2/2019 Solutions 020812

    74/248

    68 CHAPTER 7. FREQUENCY DOMAIN SOLUTIONS

    Divide both sides by i and evaluate at t = 0 to get

    1A1 = 2A2.

    Since A1 = A2, it must also be true that

    1 = 2.

  • 8/2/2019 Solutions 020812

    75/248

    Chapter 8

    Frequency Response Solutions

    1. Let A = ei (in polar coordinates), so

    Aeit + Aeit = 2Re{eit+}= 2 cos(t + ).

    From this, it is evident that = 1/2 and = /4. Hence,

    A = 0.5ei/4.

    2. Note that

    s(x) = Im

    {e(x+i2x)

    }= ex sin(2x)

    which is plotted in figure 8.1. This plot was generated by the following Matlab code:

    x = [-1:0.01:1];

    s = exp(-x).*sin(2*pi*x);

    plot(x,s)

    3. in terms of, is = . has units of seconds. has units of radians per second. hasunits of radians.

    4. By definition, x is periodic with period p if for all t Reals,x(t +p) = x(t).

    The left side here is simply (Dp(x))(t). Therefore, an equivalent definition of periodic withperiod p would be that

    Dp(x) = x.

    Since S is time invariant,S(Dp(x)) = Dp(S(x)).

    The left side is S(x) because Dp(x) = x. Hence

    Dp(S(x)) = S(x),

    so S(x) is periodic with period p.

    69

  • 8/2/2019 Solutions 020812

    76/248

    70 CHAPTER 8. FREQUENCY RESPONSE SOLUTIONS

    1 0.8 0.6 0.4 0.2 0 0.2 0.4 0.6 0.8 11.5

    1

    0.5

    0

    0.5

    1

    1.5

    2

    2.5

    Figure 8.1: Solution to problem 2.

  • 8/2/2019 Solutions 020812

    77/248

    71

    5. (a) Assume Images = [Reals Reals Y], where Y is intensities, colormap indexes, orcolors. Then Sv,h:Images Images such that for all I Images and , Reals,

    (Dv,h(I))(, ) = I( v, h).

    (b) Assume Images = [Integers Integers Y], where Y is intensities, colormap indexes,or colors. Then Sm,n:Images Images such that for all I Images and , Integers ,

    (Dm,n(I))(, ) = I( m, n).

    6. (a) Yes, it is linear. Check superposition. Ify1 = D(x1) and y2 = D(x2), then

    (D(ax1 + bx2))(n) = ax1(n

    1) + bx2(n

    1)

    = a(D(x1))(n) + b(D(x2))(n),

    so superposition applies.

    (b) Yes, it is time invariant. Note simply that

    Dm D = D Dm = Dm+1.

    7. (a) Yes, it is linear. Let y1 = TimeScale(x1), and y2 = TimeScale(x2). I.e.,

    y1(t) = x1(2t) and y2(t) = x2(2t).

    Let y = TimeScale(ax1 + bx2). I.e.,

    y(t) = ax1(2t) + bx2(2t).

    Observe from this latter equation that

    y = a TimeScale(x1) + b TimeScale(x2),

    so superposition applies.

    (b) No, it is not time invariant. Let

    y1 = (D TimeScale

    )(x)

    and

    y2 = (TimeScale D)(x).I.e.,

    y1(t) = x(2t )and

    y2(t) = x(2t 2).These are not equal for all x, so the system is not time invariant.

  • 8/2/2019 Solutions 020812

    78/248

    72 CHAPTER 8. FREQUENCY RESPONSE SOLUTIONS

    8. Write x in terms of complex exponentials:

    x(t) = ei0t + 0.5eit + 0.5eit + 0.5ei2t + 0.5ei2t ,

    and note that each term gets scaled by the frequency response,

    y(t) = H(0)ei0t + 0.5H()eit + 0.5H()eit + 0.5H(2)ei2t + 0.5H(2)ei2t .

    Then note that H(0) = 1, H() = 1, H() = 1, H(2) = 0, and H(2) = 0, so

    y(t) = 1 cos(t).

    9. (a) Ak = aAk, k Naturals0 and k = k, k Naturals.(b) A

    k = Ak, k Naturals0 and

    k = k k0, k Naturals.

    (c) A0 = A0, Ak = 0, k Naturals and k = 0, k Naturals. (Any other value for

    k is acceptable.

    (d)

    k Naturals0, Ak = |Akeik + Akei

    k |,

    and

    k Naturals, k = (Akeik + Akei

    k ).

    10. (a) LTI

    (b) LTI(c) L

    (d) L

    (e) TI

    (f) TI

    11. Note that

    x(n) = ein

    where = 0. Therefore, y = S(x) is given by

    y(n) = H()ein = H(0)

    1 =|

    sin(0)|

    = 0.

    Hence,

    y(n) = 0

    for all n Integers.12. Note that the term being summed is a periodic function ofk. Also note that it is a complex

    exponential. Summing a complex exponential over one period yields zero. The period is the

    smallest integer p such that

    5(k +p)/6 = 5k/6 + M2

  • 8/2/2019 Solutions 020812

    79/248

    73

    for some integer M. Solving for p, we find

    p = 12M/5.

    Since both M and p must be integers, we find that the period is p = 12. Thus, n = 11 willresult in summing over one period, which will result in zero.

    We can verify this more directly. Let = ei5/6. Then

    nk=0

    ei5k/6 =n

    k=0

    k =1 n+1

    1 .

    This is zero if

    1 n+1

    = 0

    or

    n+1 = 1.

    So we need to find the smallest n Naturals such that

    n+1 = ei5(n+1)/6 = 1.

    So we need to find the smallest n Naturals such that

    5(n + 1)/6

    is a multiple of2. I.e., we need to find the smallest n Naturals such that

    5(n + 1)/6 = M2

    for some integer M, or

    n + 1 = 12M/5

    which means

    n = 11.

    13. (a) Using the relations

    X0 = A0,

    Xk = 0.5Akeik , k = 1, 2,

    Xk = Xk = 0.5Ake

    ik , k = 1, 2,

    we get

    Xk =

    1, k = 00.5, k {2, 1, 1, 2}0, otherwise

  • 8/2/2019 Solutions 020812

    80/248

    74 CHAPTER 8. FREQUENCY RESPONSE SOLUTIONS

    (b) Using the results of part (a), we can write

    x(t) = ei0 + 0.5(ei2t + eit + eit + ei2t).

    Because the system is LTI, the output is

    y(t) = H(0)ei0 + 0.5(H(2)ei2t + H(1)eit + H(1)eit + H(2)ei2t).

    Since H() = cos(/2), we have H(0) = 1, H(1) = H(1) = 0, and H(2) =H(2) = 1. Thus,

    y(t) = 0.5(ei2t ei2t) + 1= cos(2t) + 1.

    (c) The fundamental frequency of the output is 0 = 2 radians/second.

    14. Note that

    x(t) = x(t) x(t 1).Since the system is LTI,

    y(t) = y(t) y(t 1).That is,

    y(t) =

    1, if0 t < 11, if2 t < 30, otherwise

    A sketch is given below:

    y(t)y'(t)

    y(t1)

    t

    15. (a) From Eulers relation,

    cos(n/2) = 0.5(ein/2 + ein/2).

    Since the system is LTI, the output is given by

    y(n) = 0.5(H(/2)ein/2 + H(/2)ein/2)= 0.5((/2)ein/2 + (/2)ein/2)

    = 0.5 cos(n/2).

  • 8/2/2019 Solutions 020812

    81/248

    75

    (b) Write the input as

    x(n) = 5ei0n

    so the output is recognized as

    y(n) = 5H(0)ei0n = 0.

    (c) Write the input as a complex exponential function,

    x(n) = ein

    so the output is given by

    y(n) = H()ein

    = ein

    =

    , n even

    , n odd

    16. (a) The sketches are shown below:

    x(t)

    t

    y(t)

    t

    (b) The sketches are shown below:

  • 8/2/2019 Solutions 020812

    82/248

    76 CHAPTER 8. FREQUENCY RESPONSE SOLUTIONS

    x(t)

    t

    y(t)

    t

    17. The system is shown below:

    H1

    H2

    18. Note that

    p(n) = 2(u(n) u(n 8)).

    Since the system is LTI,

    w(n) = 2(y(n) y(n 8))= 2(nu(n) (n 8)u(n 8))

    =

    2n 0 n < 816 n 80 otherwise

    A sketch is shown below

  • 8/2/2019 Solutions 020812

    83/248

    77

    w(n)

    n

    ...

    ...

    19. (a) Given

    y(t) = x(at)

    and

    x(t) =

    k=

    Xkeik0t

    it follows that

    y(t) =

    k=

    Xkeik0at.

    Thus, the Fourier series coefficients for y are the same as those for x, but the fundamen-tal frequency is 0a, where 0 = 2/p is the fundamental frequency for x.

    (b) Since

    w(t) = x(t)ei0t

    it follows that

    w(t) =

    k=

    Xkei0teik0t

    =

    k=Xke

    i(k+1)0t.

    Change variables, letting m = k + 1, to get

    w(t) =

    m=

    Xm1eim0t.

    Therefore, the fundamental frequency for w is the same as for x, and its Fourier seriescoefficients are:

    Wk = Xk1

    for all integers k.

  • 8/2/2019 Solutions 020812

    84/248

    78 CHAPTER 8. FREQUENCY RESPONSE SOLUTIONS

    (c) Write

    z(t) = x(t)cos(0t)

    = 0.5x(t)(ei0t + ei0t)

    = 0.5

    k=

    Xk(ei0t + ei0t)eik0t

    = 0.5

    m=

    Xm1eim0t + 0.5

    m=

    Xm+1eim0t.

    Thus, once again the fundamental frequency is the same, and the Fourier series coeffi-

    cients are

    Zk = 0.5(Xk1 + Xk+1)

    for all integers k.

    20. To see the validity of (8.33),

    Xk =1

    p

    p1m=0

    x(m)eimk0 ,

    we substitute for x(m) from (8.30) in the right-hand side to get

    1

    p

    p1m=0

    {p1n=0

    Xneinm0}eimk0 = 1

    p

    p1n=0

    Xn

    p1m=0

    eim(nk)0 = Xk,

    because ifn = k,p1m=0

    eim(nk)0 = 1 ei(nk)p0

    1 ei(nk)0 = 0,and ifn = k,

    p1m=0

    eim(nk)0 = p.

    21. (a) We need to show that for all x [Reals Reals] and t Reals,Squarer(x))(t) = f(x(t))

    for some function f:Reals Reals. Let f be such that for all u Reals, f(u) = u2.Then

    f(x(t)) = x

    2

    (t) =Squarer

    (x))(t).Hence the function is memoryless.

    (b) To show that the system is not linear, it is sufficient to show that for some a Reals andx [Reals Reals],

    Squarer(ax) = aSquarer(x).To show this, we can find any t Reals such that

    (Squarer(ax))(t) = a(Squarer(x)(t)).The left side equals a2x2(t), while the right side is ax2(t). These are not equal if, forexample, a = 2 and x(t) = 0.

  • 8/2/2019 Solutions 020812

    85/248

    79

    (c) We need to show that

    Squarer D = D Squarer.Both sides define the same function f given by

    x [Reals Reals], t Reals, (f(x))(t) = x2(t ).

    (d) Observe that

    y(t) = cos2(t)

    = (0.5(eit + eit))2

    = 0.25(ei2t + 1 + 1 + eiet)2

    = 0.5 + 0.5cos(2t),

    from which we see that the output contains a constant term and a sinusoidal term at

    frequency 2.

  • 8/2/2019 Solutions 020812

    86/248

    80 CHAPTER 8. FREQUENCY RESPONSE SOLUTIONS

  • 8/2/2019 Solutions 020812

    87/248

    Chapter 9

    Filtering Solutions

    1. (a) The impulse response is shown below:

    h(n)

    n......

    (b) When the input is given by x(n) = cos(n), where = /4, then the output is y(n) =0. From the figure showing the magnitude frequency response of the 8-point movingaverage, we see that H(/4) = 0. Since the impulse response is real, H(

    ) = H(),

    so H(/4) = 0 as well.(c) H() = 0.

    2. We can calculate the CTFT of the impulse response,

    H() =

    h(t)eitdt

    =

    30

    (1/3)eitdt

    = (1 ei3

    )/(3i).The following Matlab code plots the magnitude response:

    f = [-5:1/100:5];

    H = (1-exp(-i*3*2*pi*f))./(3*i*2*pi*f);

    plot(f,abs(H));

    Note that this gives a Warning: Divide by zero at frequency 0, but generates a correct plot

    anyway. You can use LHopitals rule to find that the value at frequency zero is 1. The plot is

    shown below:

    81

  • 8/2/2019 Solutions 020812

    88/248

    82 CHAPTER 9. FILTERING SOLUTIONS

    5 4 3 2 1 0 1 2 3 4 50

    0.1

    0.2

    0.3

    0.4

    0.5

    0.6

    0.7

    0.8

    0.9

    1

    frequency in Hz

    3. (a) Using convolution,

    y(t) =

    h()x(t )d

    =

    (( 1) + ( 2))x(t )d

    =

    ( 1)x(t )d +

    ( 2)x(t )d= = x(t 1) + x(t 2),

    using the sifting rule.

    (b) The frequency response is the CTFT of the impulse response,

    H() =

    h(t)eitdt

    =

    ((t 1) + (t 2))eitdt

    = ei + ei2,

    using the sifting rule.

    (c) The following Matlab code creates the plot:

  • 8/2/2019 Solutions 020812

    89/248

    83

    f = [-5:1/100:5];

    H = (exp(-i*2*pi*f)+exp(-i*2*2*pi*f));plot(f,abs(H));

    which yields the plot shown in figure below:

    5 4 3 2 1 0 1 2 3 4 50

    0.2

    0.4

    0.6

    0.8

    1

    1.2

    1.4

    1.6

    1.8

    2

    4. (a) The impulse response is shown below:

    h(n)

    n...... 12

    (b) Use convolution to relate the input and output

    y(n) =

    k=

    h(k)x(n k)

    = x(n) + 2x(n 1),using the sifting rule. When the input is the unit step, this becomes

    y(n) = u(n) + 2u(n 1) =

    0 ifn < 01 ifn = 03 ifn 1

    Here is a plot:

  • 8/2/2019 Solutions 020812

    90/248

    84 CHAPTER 9. FILTERING SOLUTIONS

    h(n)

    n...... 1

    3

    (c) If the input is r, then the output is

    y(n) = r(n) + 2r(n 1) =

    0 ifn 03n 2 ifn 1

    Here is a plot:

    h(n)

    n...... 1

    4

    7

    (d) The frequency response is the DTFT of the impulse response,

    H() =

    k=

    h(k)eik

    = 1 + 2ei.

    (e) For all Reals,H( + 2) = 1 + 2ei(+2)

    = 1 + 2eiei2

    = 1 + 2ei, since ei2 = 1

    = H().

    (f) For al