Math 220, Differential Equations Fall 2013 Exam 1 Solutions - 4-October-2013 Landon Kavlie 1. (25 pts) Find general solutions to the following differential equations: (1) (10 points) x dy sin(x) + 3y + x2 = dx x (2) (15 points) dy 2x + y 2 − cos(x + y) . =− dx 2xy − cos(x + y) − ey For the first one, this is a first-order linear problem. So we put it into standard form first. That is, dy 3 sin(x) + y= − x. dx x x2 Then, we introduce the integrating factor e R 3 x dx = e3 ln(x) = x3 . We then multply the equation by this value. x3 dy + 3x2 y = x sin(x) − x4 . dx d The left-hand side reduces down to dx [x3 y]. Thus, we integrate both sides giving us that Z 1 x3 y = x sin(x)dx − x5 + C. 5 Integration by parts then gives us that 1 x3 y = sin(x) − x cos(x) − x5 + C 5 Simplifying, we have that y= sin(x) cos(x) 1 2 C − − x + 3. x3 x2 5 x For the second one, this ends up being an exact equation. To see this, we crossmultiply and rearrange giving us that (2xy − cos(x + y) − ey )dy + (2x + y 2 − cos(x + y))dx = 0. Then, we see that ∂ (2xy − cos(x + y) − ey ) = 2y + sin(x + y) ∂x ∂ (2x + y 2 − cos(x + y)) = 2y + sin(x + y). ∂y 1 2 Thus, our equation is exact. So, we know that the full solution is given by F (x, y) = C where F is some function whose partial derivatives are given by ∂F = 2x − y 2 − cos(x + y) ∂x ∂F = 2xy − cos(x + y) − ey . ∂y We just have to pick one of these and integrate it. I choose the second one. Z F (x, y) = 2xy − cos(x + y) − ey dy = xy 2 − sin(x + y) − ey + g(x). To find the function g(x), we then take the derivative with respect to x and compare. That is, y 2 − cos(x + y) + g 0 (x) = 2x + y 2 − cos(x + y). This gives us that g 0 (x) = 2x and g(x) = x2 after integrating. Thus, we find that F (x, y) = xy 2 − sin(x + y) − ey + 2x. And our solution is given by F (x, y) = C That is, xy 2 − sin(x + y) − ey + 2x = C. 2. (15 pts) Solve the initial value problem for the first-order differential equation: ( y sin(x) 1 dy x dx = y 2 +1 y(π) = 1. This equation is separable. So, we just move all of the x terms to the right-hand side and all of the y terms to the left-hand side. This gives us that y2 + 1 dy = x sin(x)dx. y Now, we integrate. We integrate the right-hand side by parts giving us that Z x sin(x)dx = sin(x) − x cos(x) + C. For the left-hand side, we split up the numerator giving us that Z 2 Z y +1 1 1 dy = y + dy = y 2 + ln(y) + C. y y 2 This gives us the equation 1 2 y + ln(y) = sin(x) − x cos(x) + C. 2 We now plug in y(π) = 1 to get that 1 2 1 + ln(1) = sin(π) − π cos(π) + C. 2 This simplifies using that ln(1) = sin(π) = 0 and cos(π) = −1. We get that C = 12 − π. Thus, our solution is 1 2 1 y + ln(y) = sin(x) − x cos(x) + − π. 2 2 3 There is no way that I can see to solve for y. 3. (20 pts) Solve the initial-value problem for the second order differential equation 4y 00 − 4y 0 + y = 0 y(0) = 2 0 y (0) = 1. This is a gimme. We just write down the associated equation 4r2 − 4r + 1 = 0. This factors as (2r − 1)2 = 0 which gives us the double root r = 1/2. So, our solution is given by y = C1 e1/2t + C2 te1/2t . We now use our initial conditions to find C1 and C2 . First, we use that y(0) = 2 to get that 2 = C1 e0 + C2 · 0 · e0 = C1 . Next, we take a derivative of y getting that y0 = 1 1 C1 e1/2t + C2 te1/2t + C2 e1/2t . 2 2 Using that y 0 (0) = 1 gives us that 1 C1 + C2 = 1 + C2 = 1. 2 Thus, we find that C2 = 0 and our solution is y 0 (0) = y = 2e1/2t . 4. (20 pts) A brine solution of salt flows at a constant rate of 4L/min into a large tank that initially held 100L of pure water. The solution inside the tank is kept well-stirred and flows out of the tank at a rate of 3L/min. The concentration of salt entering the tank is 0.2kg/L. (1) (10 points) Determine the mass of salt in the tank after t min. (2) (10 points) Determine the concentration of salt in the tank when t = 2. (Do not round your answer into a decimal number.) The first problem is the standard one. Find the equation for the salt in the tank. I hope you drew a lovely diagram of the problem. I will just skip to the good stuff. First, we see that the flow rate into the tank is more than the flow rate out. So, we set up a differential equation to figure out what the volume of liquid is in the the tank at time t. For this, we do the usual compartmental analysis trick of dV = volume in − volume out = 4 − 3 = 1 dt 4 Where V (t) gives the volume of liquid in the tank at time t. Also, we have the initial data V (0) = 100. So, we solve this and find that V (t) = 100 + t. Doing the same thing for the salt, which I will label as A(t), we find that dA A = salt in − salt out = 4 · 0.2 − 3 . dt 100 + t both of the “in” and the “out” are gotten by multiplying the flow rate times the concentration. Adding the initial condition of A(0) = 0 (pure water) gives us the initial-value problem dA 3A dt = 0.8 − 100+t A(0) = 0. This is a first-order linear problem that can be solved using integrating factors. That is, we put it into standard form dA 3A + = 0.8. dt 100 + t Then, we build the integrating factor e R 3 100+t dt = e3 ln(100+t) = (100 + t)3 . Multiplying the whole equation by this and simplifying gives us that d [(100 + t)3 A] = 0.8(100 + t)3 . dt Integrating gives us that (100 + t)3 A = 0.2(100 + t)4 + C. Simplifying gives A = 0.2(100 + t) + C(100 + t)−3 . Using the initial condition A(0) = 0 gives us that 0 = 0.2(100) + C(100)−3 . This gives us that C = −2x107 . So, the solution to the first part is A(t) = 0.2(100 + t) − 2x107 (100 + t)−3 . Now for the concentration part. Remember that the concentration is given by the amount of salt divided by the volume of the liquid. That is, C(2) = A(2)/V (2). In full, 0.2(102) − 0.2x107 (102)−3 ≈ −0.18152. C(2) = 102 5. (20 pts) Consider the initial value problem dy dx = 1 + x sin(xy) y(0) = 0. (1) (5 points) Write down Euler’s method for yn+1 in terms of yn for a general step-size h. (2) (10 points) Use two steps of Euler’s method to approximate y(π). (3) (5 points) Use one step of improved Euler’s method to approximate y(π). 5 Note: The recursive formula for Improved Euler’s method is h yn+1 = yn + [f (xn , yn ) + f (xn+1 , yn + hf (xn , yn ))]. 2 The first one is easy. Just write down yn+1 = yn + hf (xn , yn ). If you want more, not that f (x, y) = 1 + x sin(xy). So, you can write yn+1 = yn + h[1 + xn sin(xn yn )]. For the second one, we use two steps, so our step-size is h = (end−start)/(number of steps) = (π − 0)/2 = π/2. Also, we use that y(0) = 0 to give us that y0 = 0 and x0 = 0. Then, plugging stuff into the formula gives us that y0 = 0 y1 = y0 + h[1 + x0 sin(x0 y0 )] = 0 + π/2[1 + 0 · sin(0 · 0)] = π/2 y2 = y1 + h[1 + x1 sin(x1 y1 )] = π/2 + π/2[1 + π/2 · sin(π/2 · π/2)] = π + π 2 /4 sin(π 2 /4). For the third one, we again plug the numbers into the formula where h = π. First, we notice that y0 + hf (x0 , y0 ) = 0 + π[1 + 0 · sin(0 · 0) = π. This will simplify things later. We then have that y1 = 0 + π/2[(1 + 0 sin(0)) + (1 + π sin(π 2 ))] = π + π 2 sin(π 2 ).