# Differential Equations and Linear Algebra, 1.4d: Solution for Any Input, q(t)

From the series: Differential Equations and Linear Algebra

*
Gilbert Strang, Massachusetts Institute of Technology (MIT)
*

To solve a linear first order equation, multiply each input *q(s)* by its growth factor and integrate those outputs*.*

OK. Finally, I'm going to solve this first order linear differential equation with a formula that works for any source term. So we've solved it for specific, nice, special source terms I'll remember later. But now we want a formula for the solution to that equation, period. And we want to understand the formula. So now, write the formula down, and then let's see why it's right. And then of course, we could put it into the equation and confirm that it's right.

OK the formula is going to be-- this is the big formula you could say, for first order linear equations. So y of t. First we have the result of the amount-- I'm thinking of this as balance. The money in the bank is why it's increasing at this rate, because of interest being added. And it's increasing at this rate because of new deposits being added. And oh, maybe I should say about those deposits, I'm not thinking of like deposit once a year, or once a month, or once a minute, even. Deposit continuously. We're talking differential equations here. Time is running all-- the clock is always running. So you're-- theoretically, at least-- you're depositing at a rate of so much per second, all the time.

OK. So first, the y of 0, that's a once in a lifetime deposit to start the account. And it grows, as we know, with the interest rate as the exponent. The question is-- so that's the null solution that matches the initial condition. No solution, because there are no deposits here. This solves this part of the equation, the null part. But now I want to add in a particular solution, and it'll be the particular solution that matches the deposits.

And I want to understand this formula. So here's the formula. I'm going to-- the deposits each deposit goes in at time T, goes in at some time, and then it grows. Once you've made the deposit, it's going to grow exponentially. With --, it will grow over the remaining time. So here's the formula. You make deposits at any time, s, between s equal 0 and s equal t.

So s is the running clock. T is the-- we look at our account and see what's in it. And this deposit is made at time s, and then it grows over the remaining time, from s to t. So it grows by a factor e to the a, t minus s. That's the key. And now we add up all those deposits with their growth. So that addition for continuous time addition is integration. That's the whole idea of the integral, is add up continuously.

So there's my formula that I'm hoping you will admire. The no solution that grows out of the initial condition. The particular solution that grows out of the source term, q. Of course I've used q of t all the way. Here I call it q of s. I have to introduce a integration variable s, which goes from the start of these deposits until the current time, and grows like that. So that's the formula. I could put a big box around it. Let me start a box anyway. I could check that it's correct. But I hope you see why it's right.

And let me make some comment on the examples of q where we didn't have this formula. We just went for it directly. So we started with, these were special. Especially nice, you could say. Q of t equal a constant. That was the first video. Then we did q of t equal an exponential. That was the second one. Then we did-- so and then we found the exponential response.

Then I did oscillation. Cosine-- well, let me put it over here-- cosine of omega t. Or plus sine of omega t. You remember, those two kind of had to come together. We couldn't stick with cosines alone, because the derivative of a cosine here would give us a sign, so signs got into the picture. So we found the formula for that, that took a little more work. And in fact we did it by a real method and a complex method.

And, now are there any other nice functions in calculus? Well the next video, I'm going to tell you about two more functions that I think are very nice. Step function. So the deposit-- we don't make any deposits up until some time, and then we start, then we go change to constant. So the step function is 0 and then a constant. And also-- and this is the especially interesting one-- a delta function.

And what is a delta function? Which doesn't always come into the basic differential equations, course, but it belongs there. Because in a model of reality, a delta function is like a golf club hitting a golf ball. In an instant something happened. Or a baseball bat hitting a baseball. It gives it an instant velocity. It's an impulse.

So step function is like a light switch off and then on. Delta function is all in one instant, an impulse, and you'll see that coming. And then those are the-- oh, and maybe I could include-- let's see, if I've got a constant, maybe should include t, t squared, so on. Powers of t are not too bad. We could get--

So for all of these special ones that I call the nice functions. For all of those-- and we could multiply t times e to the st, that would still be nice. And we could have a simple formula. Those are the ones that give simple, direct, interesting, answers in themselves. And this is the one that gives the general answer.

And if I put q be any one of those in this general formula, I'll get the special one. You can see how if I put a constant in there, that will be exactly what we found at the very, very beginning for the response to a constant. Right. So this is the general expression. I feel I should say more about it.

I guess I should say, two more things I want to add about this general formula. One is, I should check that it's correct. But I hope you saw, it had to be right. This input went in, it grew, everything was linear. So I could just add the separate growth, separate results, to find out what the balance was at the final time, t.

But still, I can check it. And I can derive it. That step is always often done by what's called an integrating factor. So there will be a quick video that shows you how an integrating factor leads to that formula. Right in this video, I'm just saying I was led to it by common sense. But I can check that it's correct. So let me check that it's correct.

OK. This part I can see is correct. So I'd like to work with that one and show that that is a particular solution to the differential equation. Can I do that? I want to show that this-- I'm looking now at this y particular, and I'll factor out the e to the at, because it doesn't depend on s. It's not involved in the integration. So this is in the integral from s equals 0 to s equal t of e to the minus as, that has an s in it. Q of s, ds. This is all the stuff that depends on what time the deposit was made, time s. And what time we're looking at the balance, the later time, t.

OK. This is a product of one term times another term. And when I put it into the differential equation, I'll use the product rule. So the derivative of that product will have two terms from the product rule. And those two terms will be-- if all goes well-- will be the two terms in the differential equation. So can I take the derivative of this by the product rule? So I take the derivative of the first thing, so now I'm computing dy, dt, by ordinary calculus. So the derivative of that is a e the at times the second term.

That's just ay. That's a times the y that we had before. Because the derivative of e to the at, by the chain rule, brings down an a, and we have that. But now the product rule says also I must take that term times the derivative of this term. And that looks messier. What's the derivative of that function? It's a function of t. But it's an integral. It's a function of t. What's it's time derivative? That's the last piece of the product rule.

Well, look what it is. It's the integral up to time t of some function. And the fundamental theorem of calculus says that the derivative of the integral is the original function, right? So the derivative of this integral is the original function that we integrated at time t. So it's e to the minus a t cubed t. That's the second term from the product rule.

And OK, this was the ay, perfectly. And what do I have here? E to the at cancels e to the minus at, and it's the source term q of t. So I have ay plus q of t, the correct right hand side for the differential equation. So this, that formula, let me bring it down once more, is sort of the climax of this beginning of the videos to see first order linear differential equations.

So what's coming now are step and delta function. I just want to speak about those. And that takes a few minutes separately. And then another step will be to allow the interest rate to change. We made our problem simple because we've kept a constant interest rate. So I'll let the interest rate change. And then after that comes the real step to non-linear equations.

So delta functions, varying interest rate, and then non-linear equations. And then on to second order equations and all the rest of the theory of differential equations. Good. Thank you.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

### Asia Pacific

- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)