Flash and JavaScript are required for this feature.
Download the video from iTunes U or the Internet Archive.
Instructor: Dennis Freeman
Description: Having established representations and analytical methods for discrete-time and continuous-time systems, today's lecture uses the example of a leaky tank to show how Euler and trapezoidal approximations can convert a continuous system to a discrete one.
Lecture 7: Discrete Approxi...
The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high quality educational resources for free. To make a donation or view additional materials from hundreds of MIT courses, visit MIT OpenCourseWare at ocw.mit.edu.
PROFESSOR: Today what we've been doing, we've been looking at how there's a lot of different representations for CT systems. They look almost the same as a lot of representations for DT systems. And today I want to go one more step and show how there's actually a bunch of relationships between them. That's when things become very powerful.
And so I want to do that by thinking about a very simple example, thinking about a CT system and how you would convert that CT system into a DT representation. This is a problem we've worked on before, the leaky tank system. We've already seen a gazillion representations for it.
We can think about the leaky tank system as a differential equation. We derive that in Lecture One. We can think of it as a block diagram, Lecture One.
We can think about it as a functional. That was about two lectures ago. As a system function, that was Laplace transforms, that was about a week ago.
We can think about an impulse response because the fundamental signal in CT, the thing that plays the same role as the unit sample in DT, is the unit impulse. So we can think about the impulse response.
And there's a variety of connections between all of those. What I want to do today is compare the step response of the leaky tank system to the step response of a DT approximation to the tank system.
To get started then, I want to figure out the step response of the leaky tank system. For you, you should think about this as practice for the exam. You should be able to do this in 30 seconds. So start. Compare your answers to your neighbor. Figure out what is the step response for the leaky tank system.
[INTERPOSING VOICES]
No. No. OK, this question is too simple so we're going to blast ahead. What's the answer? What's the step response for the leaky tank system? Everybody raise your hand. Let me see how many numbers.
OK, it's not quite as high a fraction as I would have liked. Take another 15 seconds. Or better yet, talk to your neighbor. Explain your answer to your neighbor and let your neighbor tell you why you're wrong.
[INTERPOSING VOICES]
OK, re-vote. So what's the step response of the leaky tank system? Better. Better, better, better, better, better, better. OK, almost 100%. Not quite.
Another question. How many ways can you find the step response of the leaky tank system? One represents more than one. I'm not going to have a representation for 0, right. More than one, more than two, more than three, more than four, more than five. How many ways can you find that? Don't just stare at me with blank looks.
OK, what's a good way to find the step response of this system? You can shout, that way I won't be able to identify where you're coming from and I won't be able to point to you. But you have to be quick because if I see your mouth move then I'll know which one you are. So when I look at it this way you shout over here, right. There's simple ways to do this, right. What's a good way to find the step response of the leaky tank system?
AUDIENCE: You have the transfer function [? magnetized ?] with one bias then we have the [INAUDIBLE]
PROFESSOR: That's a relatively advanced way and it's completely correct. Could somebody tell me an even simpler way. Yes?
AUDIENCE: What's the behavior as t goes to infinity.
PROFESSOR: OK. What is it? Let's do something easier. What's the input?
[INTERPOSING VOICES]
PROFESSOR: Well, it's a unit step, right. So the input is some unit step thing right. So my input, if I think about some input r0 of t, the input is something that looks like that. So if I look at, like you suggested, if I look at what's going to happen for t goes to infinity, what's going to happen?
AUDIENCE: Eventually the rate at which we're going out is going to be the same as the rate that's going it.
PROFESSOR: So based on that, do I like this one, this one, this one, this one, or that one?
AUDIENCE: So, it knocks out one and three.
PROFESSOR: Knocks out one and three because we're not expecting it to go to zero because the input didn't go to zero. Good. OK, so it's maybe this, or this, or that. What's a good method? What's a good method? Yes?
AUDIENCE: So the thing that confused me is that in the original problem on the problem set we had it was a second order system, but this one's a first order.
PROFESSOR: This is first order.
AUDIENCE: Yeah, so then you know that it's going to look like something's that's first order.
PROFESSOR: Still looks like something that's first order. That's good. I asked the question here and I flicked back here, that was a clue. How many ways can you think of to do this problem? Five ways. OK.
You could think about solving it by looking at the differential equation. How about how many of you could do that? OK, how many of you took 1803? Ah, good, good. So all of you could do it by doing the lower left-hand corner, right? OK, you could all do it that way.
You could all do it with block diagrams, right. We thought about how you put a signal into a block diagram and you can chase it around its end, right. You could do it that way. So there's at least five ways.
Just as rehearsal, I'm sharing two ways here that don't quite fall there, so my answer would have been at least seven ways that I can do this problem. Because I'm going to show you two new ones that don't appear directly. One way is to think about the differential equation, solving for t less than zero and t greater than zero. Paste the solutions together. With me so far?
So solve it for t less than 0, the answer is 0 because there was no input. It started at rest. Solve it for t bigger than 0. That means the input is 1. So you can get some answer for t bigger than 0.
Paste the two solutions together by using step functions. Put the total answer back into the differential equation. That total answer better have the property that it solves the differential equation for all time. OK. Nod your head yes. It will make me feel like I'm doing a fantastic job.
The only trick there is thinking about how do you do things like differentiating unit step function. But the derivative of a unit step function is delta function. The derivative of one of these things, which looks like a product of something that exists for all time and something that turns on at 0, it's just a product rule. Derivative of the first times the second, plus second times the derivative of the first. Except I said the same thing twice. OK.
And so if you do that, you end up finding out that to match the delta functions and the u functions, it places additional constraints on the constants and the answer looks like this. OK, everybody sort of sees what I'm saying?
Here's a different way you can do it. You could think systems. So on the chart I told you what the unit's impulse response was. It's 1 over tau u to the minus t over tau u of t. So you could use that to figure out the response.
If I know that delta goes into a system, it gives me the unit impulse response h of t. And the question then is, find the unit step response. Well, there's an easy way to find the unit step. That's just the integral of the unit impulse. So apparently, the unit step response of this thing is the same as the unit impulse response of this combined system.
But we know from our analysis of systems that you're allowed to commute things. So that means I can flip this order. Which means then that all I need to do is integrate the impulse response of this thing, which I knew by assumption. So if I integrate the impulse response, I get the step response. That's another way of doing it.
I could do it by Laplace transforms, I could do it a gazillion ways, right. Easy. You should go home and make sure you can do all of those.
OK, so the answer then was number two. It's this thing. It's the first order response, like we said. It has to go to a particular final value, which is equal to the final value of the input. There's a variety of ways that you could get that.
OK, the point of today then is to take that unit sample response and figure out ways to approximate it. What I want to do is think about how I would make a discrete representation for the CT system, the leaky tank system. You've done this in homework. This was homework one. I'm trying to do is get some new perspective by thinking about all those representations that we have on the answer that you already derived in homework one.
So if I wanted to represent this system, the leaky tank system, by a difference equation, one way to get the difference equation is to make an approximation to the derivative based on differences. The easiest way to do that is something that we will call the forward Euler method. In the forward Euler method, what we do is we think about all the functions of time.
Say we have an x function of time and a y function of time, the input and the output. I've got the continuous version and the discrete version, that's the sub c and the sub d. The way I could make an association between discrete and continuous is by sampling the signals. So I could say that if I knew x sub c of t, that's going to be some squirrely function but I don't know the answer, I don't know what that is.
But whatever it is, I will say that the discrete version at time n is the same as the continuous version at time n times t. t is a sampling interval. And the discrete version of this y function, this output function, at time m plus 1t is the m plus 1 sample of the discretized output signal.
Then the trick to solving the differential equation-- remember the differential equation looked like tau y dot of t is x of t minus y of t. I need to have a way of thinking about this y dot thing. A way of thinking about the y dot thing would be the slope of the line that connects this sample to the next sample. We call it forward Euler because at time n we approximate the derivative at time n by looking forward. So we approximate the derivative of y continuous at time nt by looking forward, yd of n plus 1 minus yd of n over t.
Then all we need to do is make that substitution into the differential equation and it turns it into a difference equation. So if I make the substitution that y dot is given by this kind of an expression, substitute into this expression. I get a difference equation that is in some sense equivalent to the original differential equation. I can solve that difference equation and I get that bottom difference relationship. That's what you did in homework one.
If you were to plot that answer, here's what you would get. The blue curve represents the solution to the leaky tank problem, the continuous problem. 1 minus e to the minus t over tau, quantity u of t. So that's the blue line.
If you select the sampling interval to be small compared to tau-- tau was the time constant for the CT system-- if you select the sampling interval to be small, 0.1, the samples that you calculate fall right on top of the line. Great. That's what we would want, right. We're trying to make a DT approximation. If our approximation worked the solution to the DT equations should be the same, in some sense, as the solution to the CT equations.
But if you change capital T, you get something that looks decreasingly like the continuous version if you make T step bigger and bigger per time. T is a sampling interval. If I started with a small sampling interval, I got a good approximation. By the time I get the sampling interval up to 2T, this solution to the DT problem looks nothing like the solution to the CT problem.
OK, that's a general problem in a numerical method. So what we're really talking about is analysis of numerical methods. What went wrong? Why is it that the approximation worked well and didn't work well?
I mean, it's intuitively clear that that's what you should have done but we'd like to be a little more formal and we'd like to be a little more quantitative. What was it that went wrong? So to get some insight let's figure out the pole for the DT system. Where's the pole?
OK, where's the pole? Where is the pole of the DT system? Not a large voter turnout, but 100% among those who turned out. So the answer is number two.
It's pretty simple to see how that would be the answer if you start with the difference equation. It's very simple to write as e transform. This evaluate y at m plus 1 is the reverse of a delay, it's an advance. Delay is multiplied by z minus 1, so advance is multiplied by z. So you can take the z transform of the difference equation to derive the z transform of the system function.
And then clearly there a pole here at z equals 1 minus T over tau. So the answer was number two. And it gives us a way to think about why the difference solution didn't work well. What we can see is that even though you remember-- what was the pole of the CT system? What's was the pole of the CT system? How do you think about the pole of a CT system?
AUDIENCE: [INAUDIBLE]
PROFESSOR: Close. What's the pole of the CT system?
AUDIENCE: [INAUDIBLE]
PROFESSOR: Minus 1 over tau. So we would do the same sort of thing, but now with a Laplace transform, right. So we would say that we could write Laplace transform of this. This would be s tau y is x minus y. And the pole that we get in the s plane it's going to be 1 over 1 minus, minus 1 over tau.
Despite the fact that the pole in the s plane was the same for all the simulations, the simulations, the discrete versions, look different. And that's because the pole for the DT system is not the same. The pole for the DT system depended both on tau, as did the pole for the CT system. But the DT system the pole depended also on capital T.
So we said that the pole, you remember the solution to the last problem, the pole was at 1 minus T over tau. So if T over tau is 0.1, the pole is at 0.9. If T over tau is 0.3, the pole is 0.7. If the pole is at 2, it's 1 minus 2 is minus 1.
So the pole for the DT system depends on both T and tau. And it's given formally by this relationship. The equivalent pole in the DT system is 1 minus T over tau. So the pole in the CT system was minus 1 over tau. The pole in the DT system moved.
The amazing thing is that the correspondence between where the pole in the CT system was and where the pole in the DT system is, is completely determined by the forward Euler method. It has nothing to do with the particular problem. OK.
We just figured out the map between the pole in the s domain and the pole in the z domain for a particular problem for the leaky tank. It turns out that that same map holds for every differential equation. So what I want to think about now is how you would prove such a statement. So, think about regardless of the CT system that we're thinking about, I can always write it in block diagram form with adders, integrators, and gains.
So for the leaky tank system that was easy. My system looked like-- I had 1 over tau, integrate add. So my system for the leaky tank system looked like that.
So the point is that there there's an A there. The Euler forward relationship is telling me how I can figure out a DT representation for the A function. So let's think about what A is. A is a thing that in CT, if the output of A is y, what's the input to A?
AUDIENCE: The derivative.
PROFESSOR: It's the derivative. So the input we would want to call y dot. So I might say that's x. So if the input is x, which is y dot, I put it through and A box and it comes out y.
So what's the Euler forward rule saying? So the Euler forward rule says that if I want to compute x of n, the n sample of this thing, I should do y dot. But y dot, I'm doing Euler forward I should look ahead. So I should compute y dot as y of n plus 1 minus y of n, divide by t. OK.
Now if I want to make a DT equivalent system what I'd like to have is some kind of a box that I could put x of n in and get y of n out. If I had such a box then I could replace every A in my CT block diagram with this new box that depends only on delays. So let's think about what would be in that box. If I wanted to make w of n out of x of n according to this rule, what would I do?
Well, let see, y of n plus 1 should be y of n added to T x of n. So if I want to compute y of n plus 1. Oh dear, what's y of n plus 1. How do I generate-- my output I want to be y of n. Where's y of n plus 1? If I knew y of n, how I compute y of n plus 1?
AUDIENCE: [INAUDIBLE]
PROFESSOR: It would be back one. So if I had an R here, what would be the name of this guy? This would be y of n plus 1, right? Delays have the property that their output is minus 1. I need a signal that's plus 1.
So I need the reverse of a delay, which I can implement by having this y signal being generated by an R. Then this equation says that in order to compute y of n plus 1, this thing, what I need to do is add this to that. So I need to add this to that. OK.
The Euler forward rule says, if I want to make a discrete approximation to the relationship between y at the output and its derivative at the input, I should make one of those boxes. OK. I have a rule now. Regardless of my CT system, I'll take every integrator and stick one of those in it. And what I'll have is a DT approximation to my CT system that's everywhere based on the Euler forward rule. Is that clear?
So now I have a rule for converting an arbitrary CT system into an equivalent DT system. Equivalent in the sense of Euler forward. And I know that that transformation will hold.
But it's even better than that. Because I can now say something about the relationship between the position of the pole in the CT system and the position of the pole in the DT system. Because I know this original system, the A, I'm going to think of A as being 1 over 2. That's the Laplace transformation. And I want that to be equivalent, according to this map, to some transformation in z.
So I can look at this thing and I can see well, that system function, if I represent that whole block by a system function, the system transformation it looks like that. But R, that's the same as 1 over z. But that's the same as T over z minus 1. Apparently, there's a relationship between s and z. In fact, z minus 1 is sT. z is 1 plus sT.
Regardless of what CT system I started with, if I use the Euler forward relationship to make an approximation of the integrator the resulting transformation will always have that property. That's exactly what we saw over here. So we think about the A's in the original system being mapped to something that's a little bit more complicated, showed here. But it's a DT representation. And that DT representation always has this property, that wherever the poles were in s I can find where the poles were in z by taking z equals 1 plus sT.
That's how we get the dependence on T. If the original pole was like over here at minus 1 over tau, we just put s equals minus 1 over tau, and we get precisely this relationship that we got before. The 1 plus sT, which is what I found here, is the same as the 1 minus T over tau that we found for the particular example of the leaky tank. Yes?
AUDIENCE: I think you mentioned this earlier, but this is purely because of the mechanics of the forward Euler method?
PROFESSOR: Because of forward Euler. This is only true if I decide that all of my integrators are approximated using the forward Euler rule. It's absolutely true. OK.
And that's a very interesting result. What it says is that if I think about how were the poles distributed in the s plane, I just used that rule to figure out how they'll be distributed in the z plane. The rule says take the s plane pole, scale it by capital T, and then shift the answer by 1.
Well, that's pretty interesting. Because that means that there are s's over here that when I go through that map end up outside the unit circle. That's exactly what I found. That transformation has the property that it can map a stable CT system, a perfectly well-behaved CT system, into an oscillatory or even a growing divergent DT system.
And you can see that simply because of the map between z and s. Had s been some number over here, the unit impulse response of the CT system would have been completely well-behaved, e to the minus sT. But the response to the DT equivalent would be badly behaved because it would have mapped outside the unit circle. OK?
And as you motivated, the that's only true because I did Euler forward. I can do precisely the same analysis for backward Euler. Instead of approximating derivatives by looking forward in time like I did before, I could instead look backward in time. If I look backward in time it looks almost the same.
Now I say the derivative at the time n cap T is n minus n minus 1. Look backwards. Seems like a trivial difference. But in fact the answer comes out completely different. If I look backwards in time instead, what I can think about now is replacing every one of these A operators again.
So I think about A. A was this thing that y came out of and y dot must have gone into, which was x. And now I'm using Euler backward instead. So now I want x of n should look backwards in time. So I want y of n minus y of n minus 1 divided by T.
So what this says is that I want to take y of n should be y of n minus 1, added to T times x of n. So that's a system that if I started with x of n and I wanted to generate y of n, it's almost the same as the other one. Except now it says, when I want to construct y of n, start with a delayed version of y.
How do I get a delayed version of y? Delay it. So I take y and I delay it like that.
What comes out here is y of n minus 1. And then y of n is y of n minus 1, added to T times x of n. So it's like that. It's almost the same, but the math is different. So now I'm replacing my A's, which are always 1 over s, with a system that looks like T going forward divided by 1 minus R in the bottom.
So that's T over 1 minus 1 over z. So that's zT over z minus 1. So that means that z minus 1 now is sTz. Cross multiplying 1 minus sT on z is 1. So z is 1 over 1 minus sT.
I got something that looks completely different. This is backward Euler. This is forward Euler. So the answer for forward Euler over here is 1 plus sT. The answer for backward Euler is 1 over 1 minus sT. Everybody with me?
So now when I think about where do the poles land, if I make the backwards Euler approximation they fall on this relationship instead of the previous. And the interesting thing about that relationship is that if you think about the way this works every point in the left half plane of s, according to this map, ends up inside a little circle in the z domain. The entire left half plane maps into the circle that's shaded in the right. If you just make a picture.
If you just plug in s equals 1, where does s happen? Plug in s equals minus 1, where's the new z? Plug in s equals 1 over T, where's the new z? All of the values in the left half plane for s map inside a small circle in the z plane. Which means that if the original system had a pole anywhere in the left half plane-- remember left half planes, left-sided.
We're thinking that those are the kinds of systems whose unit impulse responses converge toward 0. If you had a system that had poles in the left half plane and you do the backwards Euler transformation, you're guaranteed to get a system that has poles inside the unit circle. In fact, they're in a smaller circle than the unit circle. OK. Everybody sort of know what I'm talking about?
So this is the idea of thinking about, not relationships among DT representations, or representations among CT systems, but relations between CT and DT. It's because we can cast each of those kinds of systems into a polynomial representation that we can make a correspondence between the CT system and the DT approximation.
I'll talk about just one more, and that's the trapezoid rule, which is what you did in homework two. You may remember homework two, right. Since it was due, like, yesterday.
So the last problem in homework two had to do with finding a numerical approximation to the mass and springs system. And you remember, we did three of them. Those three were actually forward Euler, backward Euler, and trapezoidal rule.
Trapezoidal rule says, OK, I didn't like this idea of looking forward, that seems anti-symmetric. What's special about forwards or backwards? That's also treating backwards special. I want to treat it symmetric in time. That's what the center difference approximation did. The center difference approximation in homework two was based on a trapezoidal rule.
The trapezoidal rule says, OK, let me approximate my DT output. Let me think about a sequence of samples in a DT output, y to n. Let me force the differential equation to be true at every point between samples. In the forward Euler and the backward, we force the differential equation to be true at integers n. That made us compute derivatives by looking forward or backwards.
In a trapezoidal rule we force the differential equation to be true between samples. Then we say, OK, the signal yc should be the average of those samples. And the derivative should be the difference of the two samples divided by T. So they're centered. Everybody see that?
So we're going to force the differential equation to be true at points between the samples of the difference equation. And that's going to give me a different kind of relationship that looks strikingly the same as these kinds of relationships.
OK, so now I'm going to say that I would like to have A, which maps y, y dot is x. Except now what I'm going to want to say is that x-- which I will represent as the average of the nth and nth minus 1-- should be constrained to be the derivative of this guy, which I will do by looking at the corresponding values of y. OK?
So that gives me a different way of doing the approximation. I get y of n should be y of n minus 1, plus T over 2, x of n plus x of n minus 1. Just a different rule for how to do the derivative, that's all I've done. But it gives me a different kind of a system.
Now I want to have x of n go into something that I will make my new A boxes. To compute y of n I should have a delayed version. Well, that's easy. I make one of those. And y of n should be the sum of the delayed version.
And T over 2 times a delayed version of x. So I have to do this. So now I have the sum of x and a delayed version of x. And I put that through T over 2. So here is my new discrete approximation to the accumulator.
And I do just the same thing I did before. I say, what's the relationship between s and z? So my A, which is the same as 1 over s, now becomes that block diagram, which looks like T over 2. Looks like r plus 1. Let's see, 1 plus R. Lets do it the other way.
So T over 2, 1 plus R, 1 minus 2. So T over 2 from here, 1 plus R from here, 1 over 1 minus R from there. Which I can convert into z and I'll get T over 2, z plus 1 over z minus 1. I don't think I made any mistakes yet.
So then I get z plus 1-- z minus 1. Bring that over there, bring that over there. sT over 2, z plus 1. Now bring the z's over here. 1 minus sT over 2 operate on z to give me 1 plus sT over 2. So z is 1 plus sT over 2, over 1 minus sT over 2.
So that's my new transformation based on the trapezoidal rule, which is showed here. Hopefully they match. So z maps to 1 plus sT over 2 divided by 1 minus sT over 2.
And the interesting thing about that transformation is that it map the entire left half plane of s precisely into the unit circle. That was the reason that the trapezoidal rule worked so much better on the problems you tried in homework two. So if the pole starts out being real so that it's someplace in the s plane on this red arrow.
Euler forward gave us a pole in the z plane that could be, if T is big enough, outside the unit circle. In the Euler backwards method, it always lands someplace in the unit circle. In the trapezoidal rule it lands someplace in the unit circle.
But in the mass spring problem and the poles were on the imaginary axis, which means that in the Euler forward method, the poles went outside the unit circle. That's the reason the solution to the mass spring problem diverged. In the Euler backward method, the poles that were on the j omega axis mapped to the perimeter of this inside circle. That's why they converged, even though the mass spring system should have isolated forever in the solution that you did with Euler backwards. It converged, and that's because the method maps poles on the j omega axis inside the unit circle.
That's not what we want. What we want for the mass spring system is to map the j omega poles directly onto the unit circle so that pure oscillations over here correspond to pure oscillations over there. And that's exactly what the trapezoidal rules does.
OK, so the point then-- and this was the solution to that homework problem. So the point is that not only are we interested in figuring out relationships among the different representations for CT systems and among the different representations for DT systems, there's a lot of insight that you can get especially into things like numerical approximations by thinking about how the relationships in one domain map to the other.