Lecture 4 - Solving differential equations dy + p(t)y = g(t) dt dy In the previous lectures, we learned to solve differential equations of the form = ay − b. If we allow dt nonconstant functions in the place of constants a and b, then we get equations of the form dy dy = p(t)y + g(t) and these can, of course, be easily rearranged into the form + p(t)y = g(t). In this dt dt lecture, we will learn to solve differential equations of this form. This will allow us to obtain a solution to the differential equation concerning electrical circuits we encountered at the end of the previous lecture. The key to solving differential equations of this form will be the the product rule of derivatives. The product rule tells us how to find the derivative of a function when it is a product of two functions and we already know the derivatives of both of them. Let us recall the product rule. Product Rule of Derivatives: dg df = h(t) + g(t) dh If f (t) = g(t)h(t), then dt dt dt Slogan: “derivative of first · second + first · derivative of second” It follows from the product rule that: R dg h(t) + g(t) dh dt = g(t)h(t) + C. dt dt Problem: Solve the differential equation dy 1 1 + y = et/3 , dt 2 2 and find limt→∞ y. dy = ay − b, we need to manipulate our Solution: As in the method to solve equations of the form dt differential equation into a form where we can integrate both sides! The trick here will be to find a function µ(t) such that when we multiply every term of our equation by µ(t) dy 1 1 µ(t) + yµ(t) = µ(t)et/3 dt 2 2 we will be able to integrate the left hand side using the product rule as above! dµ Notice that IF it so happens that = 12 µ(t), then the left side is the result of the product rule! dt We get: R dy R dy dµ µ(t) + 12 yµ(t) dt = µ(t) + y dt = yµ(t) + C. dt dt dt The right side integration is straightforward. Step 1: Find the differential equation for µ(t). dµ = 12 µ(t) dt Step 2: Solve the equation to find µ(t). We already learned to solve equations of this kind: dµ dt = 1 2 µ(t) dµ R dt R dt = 21 dt µ(t) ln |µ(t)| = 12 t + E |µ(t)| = F et/2 µ(t) = Get/2 Since such a µ(t) will work for ANY G, we might as well pick the G that gives us the simplest expression, namely G = 1. µ(t) = et/2 Step 3: Multiply both sides of the equation by µ(t) = et/2 . dy t/2 1 t/2 e + 2 e y = 12 et/3 et/2 = 21 e5t/6 dt 1 2 Step 4: Integrate both sides! R R dy t/2 1 t/2 5t/6 dt e + 2 e y dt = 1 2e dt R 1 5t/6 1 6 5t/6 Right side: 2 e dt = 2 · 5 e + C = 53 e5t/6 + C R dy t/2 1 t/2 Left side: e + 2 e y dt = yet/2 + D dt So yet/2 + D = 35 e5t/6 + C. Step 5: Solve for y. yet/2 = 35 e5t/6 + E 3 5t/6 e +E y = 5 t/2 = 35 et/3 + Ee−t/2 e y= 3 t/3 e + Ee−t/2 5 It remains to find limt→∞ 35 et/3 + Ee−t/2 . As t → ∞, the term Ee−t/2 → 0. So limt→∞ 53 et/3 + Ee−t/2 = limt→∞ 53 et/3 = ∞. Problem: Solve the differential equation t dy + 2y = 4t2 , dt with the initial condition y(1) = 2. Solution: dy First we notice that the equation is not in the form + p(t)y = g(t). So we need to perform algebraic dt manipulations to bring it into that form. dy Step 0: Bring the equation into the form + p(t)y = g(t). dt dy 1 + t 2y = 1t 4t2 (t 6= 0) dt The condition t 6= 0 will be important to the final solution! dy 2 + t y = 4t dt Step 1: Find the differential equation for µ(t). dµ dy µ(t) + y = µ(t)4t dt dt dy µ(t) + 2t yµ(t) = µ(t)4t dt dµ So = 2t µ(t). dt Step 2: Solve the equation to find µ(t). dµ The equation = 2t µ(t) does NOT have the form y 0 = ay − b because a is not constant! But nevertheless dt the same method works for equations of the form y 0 = p(t)y as well. It only fails to work once we add a nonzero g(t) term! dµ dt = 2 t µ(t) dµ R dt R dt = 2t dt µ(t) ln |µ(t)| + C = 2 ln |t| + D ln |µ(t)| = 2 ln |t| + E = ln |t|2 + E 2 eln |µ(t)| = eln |t| +E 2 |µ(t)| = eln |t| eE = F |t|2 = F t2 µ(t) = Gt2 Choosing G = 1 as before, we get: µ(t) = t2 3 Step 3: Multiply both sides of the equation by µ(t) = t2 . dy 2 2 2 t + t t y = t2 4t dt dy 2 t + 2ty = 4t3 dt Step 4: Integrate both sides! R dy 2 R t + 2ty dt = 4t3 dt dt R Right side: 4t3 dt = t4 + C R dy 2 2t Left side: t + y dt = yt2 + D dt 2 4 So yt + D = t + C. Step 5: Solve for y. yt2 = t4 + E 4 y = t +2 E t y = t2 + E/t2 (t 6= 0) The restriction t 6= 0 comes from the beginning of the problem! Finally, we solve for E using the initial condition y(1) = 2. y(1) = 12 + E/12 = 1 + E = 2 E=1 y = t2 + 1/t2 (t > 0) The reason we impose the restriction t > 0 instead of t 6= 0 is that we always want a solution on an interval of the line including our initial condition. Our initial condition is t = 1 and we know that t 6= 0. So the interval t > 0 is the maximum chunk of the line avoiding the forbidden value of t and including the initial condition. Problem: Solve the differential equation dy − 2y = 4 − t, dt and find limt→∞ y. Solution: Step 1: Find the differential equation for µ(t). dµ dy µ(t) + y = µ(t)(4 − t) dt dt dy µ(t) − 2yµ(t) = µ(t)(4 − t) dt dµ Therefore = −2µ(t). dt Step 2: Solve the equation to find µ(t). dµ dt = −2 µ(t) dµ R dt R dt = −2 dt µ(t) µ(t) = Ge−2t Choosing G = 1 as before, we get: µ(t) = e−2t Step 3: Multiply both sides of the equation by µ(t) = e−2t . dy −2t e − 2e−2t y = e−2t (4 − t) dt Step 4: Integrate both sides! R dy −2t R e − 2e−2t y dt = e−2t (4 − t) dt dt Right side: we use integration by parts. 4 Let review where the formula for integration by parts comes from. R us briefly 0 0 f (t)g (t) + f (t)g(t) dt = f (t)g(t) R R f (t)g 0 (t) dt + f 0 (t)g(t) dt = f (t)g(t) Integration by Parts formula: Z Z 0 f (t)g (t) dt = f (t)g(t) − f 0 (t)g(t) dt R −2t e (4 − t) dt: f (t) = 4 − t g 0 (t) = e−2t 0 f (t) = −1 g(t) = − 21 e−2t R −2t R 1 −2t −2t e (4 − t) dt = − 1 e (4 − t) − dt = − 21 e−2t (4 − t) − 12 (− 21 e−2t ) = − 12 e−2t (4 − t) + 14 e−2t + C 2e R dy −2t 2 −2t Left side: e − 2e µ(t)y dt = ye−2t + D dt So ye−2t + D = − 21 e−2t (4 − t) + 41 e−2t + C Step 5: Solve for y. ye−2t = − 12 e−2t (4 − t) + 41 e−2t + E 1 1 − e−2t (4 − t) + e−2t + E 2 4 y= e−2t 1 1 7 1 2t 2t y = − 12 (4 − t) + 41 + Ee2t = − 1 2 · 4 + 2 t + 4 + Ee = − 4 + 2 t + Ee 7 1 y = − + t + Ee2t 4 2 7 1 2t It remains to find limt→∞ − 4 + 2 t + Ee . If E > 0, then limt→∞ − 74 + 12 t + Ee2t = ∞ if E < 0, then limt→∞ − 47 + 12 t + Ee2t = −∞ if E = 0, then y = − 47 + 12 t and limt→∞ − 47 + 12 t = ∞ General Formula: dy Solve + p(t)y = g(t). dt Step 1: Find the differential equation for µ(t). dy dµ µ(t) + y = g(t) dt dt dy µ(t) + p(t)µ(t)y = g(t)µ(t) dt dµ So = p(t)µ(t). dt Step 2: Solve the equation to find µ(t). dµ dt = p(t) µ(t) dµ R dt R dt = p(t) dt µ(t) R ln |µ(t)| + C R = p(t) dt ln |µ(t)| R= p(t) dt + D R R µ(t) = e p(t) dt+D = eD e p(t) dt = Ee p(t) dt The simplest possible such µ(t) has E = 1. So we chose: R µ(t) = e p(t) dt R Step 3: Multiply both sides of the equation by µ(t) = e p(t) dt . R R dy R p(t) dt e + e p(t) dt p(t)y = e p(t) dt g(t) dt Step 4: Integrate both sides! 5 R R dy R p(t) dt R R e + e p(t) dt p(t)y dt = e p(t) dt g(t) dt Rdt R R ye p(t) dt + C = e p(t) dt g(t) dt Step 5: Solve y. R R Rfor dt p(t) dt ye p(t) = e g(t) dt + D Z R p(t) dt e g(t) dt D R + R p(t) y= dt e p(t) dt e Problem: Solve the differential equation 2 dy + ty = 2, dt with the initial condition y(0) = 1. dy Solution: First we need to bring the equation into the form + p(t)y = g(t). dt dy + 2t y = 1 dt Using the general formula: R 2 µ(t) Z = e t/2 dt = et /4 2 et /4 dt + tE 2 e /4 R −t /4 t2 /4 y=e ( e dt + E) R 2 2 So it remains to find et /4 dt, but the problem is that the antiderivative of et /4 is not expressible in R 2 terms of the standard functions that we operate with. Therefore the function F (t) = et /4 dt can only be approximated numerically! But even to approximate it numerically we MUST have some bounds on the integral (see Lecture 1)! From the problem, we have an initial condition for y and this will give us bounds for the integral! Let us see how. R 2 2 y = e−t /4 (F (t) + E) (F (t) = et /4 dt) y(0) = e0 (F (0) + E) = F (0) + E = 1 E = 1 − F (0) 2 y = e−t /4 (F (t) + 1 − F (0)) 2 y = e−t /4 (F (t) − F (0) + 1) Rt 2 But F (t) − F (0) = 0 e−s /4 ds! Notice that we changed the variable under the integral from t to s. The reason for that is very simple: otherwise t is used in too many places and it gets confusing. Once you have a definite integral (meaning it has bounds), you can use any letter to designate the independent variable of the function you are integrating because the end result is a number anyway. Z t 2 2 y = e−t /4 ( es /4 ds + 1) 0 R5 2 For example: y(5) = e−25/4 ( 0 es /4 ds + 1) where we will use areas of rectangles to approximate the R5 2 integral 0 e−s /4 ds. y= 2 e2t /4