[Notes on Diffy Qs home] [PDF version] [Buy cheap paperback version]

[next] [prev] [prev-tail] [tail] [up]

1.4 Linear equations and the integrating factor

Note: 1 lecture, §1.5 in [EP], §2.1 in [BD]

One of the most important types of equations we will learn how to solve are the so-called linear equations. In fact, the majority of the course is about linear equations. In this lecture we focus on the first order linear equation. A first order equation is linear if we can put it into the form:

y′ + p (x)y = f (x).
(1.3)

Here the word “linear” means linear in y and  ′ y ; no higher powers nor functions of y or  ′ y appear. The dependence on x can be more complicated.

Solutions of linear equations have nice properties. For example, the solution exists wherever p(x) and f (x) are defined, and has the same regularity (read: it is just as nice). But most importantly for us right now, there is a method for solving linear first order equations.

The trick is to rewrite the left hand side of (1.3) as a derivative of a product of y with another function. To this end we find a function r(x) such that

 d [ ] r(x)y′ + r(x)p(x)y =---r(x)y . dx

This is the left hand side of (1.3) multiplied by r(x) . So if we multiply (1.3) by r(x) , we obtain

d [ ] dx-r(x)y = r(x)f(x).

Now we integrate both sides. The right hand side does not depend on y and the left hand side is written as a derivative of a function. Afterwards, we solve for y . The function r(x) is called the integrating factor and the method is called the integrating factor method.

We are looking for a function r(x) , such that if we differentiate it, we get the same function back multiplied by p(x) . That seems like a job for the exponential function! Let

 ∫ r(x) = e p(x)dx.

We compute:

 ′ y + p(x)y = f (x ), ∫ p(x)dx ′ ∫ p(x)dx ∫ p(x)dx e y + e p(x)y = e f(x), d--[∫ p(x)dx ] ∫ p(x)dx dx e y = e f(x), ∫ ∫ ∫ e p(x)dxy = e p(x)dxf(x) dx + C, (∫ ) - ∫ p(x)dx ∫ p(x)dx y = e e f(x) dx + C .

Of course, to get a closed form formula for y , we need to be able to find a closed form formula for the integrals appearing above.

Example 1.4.1: Solve

y′ + 2xy = ex-x2, y(0) = - 1.

First note that p(x) = 2x and  2 f (x ) = ex-x . The integrating factor is  ∫ 2 r(x) = e p(x)dx = ex . We multiply both sides of the equation by r(x) to get

 x2 ′ x2 x-x2 x2 e y + 2xe y = e e , d [x2 ] x ---e y = e . dx
We integrate
 2 ex y = ex + C, x-x2 -x2 y = e + Ce .
Next, we solve for the initial condition - 1 = y(0) = 1 + C , so C = -2 . The solution is
 2 2 y = ex-x - 2e-x .

Note that we do not care which antiderivative we take when computing  ∫ e p(x)dx . You can always add a constant of integration, but those constants will not matter in the end.

Exercise 1.4.1: Try it! Add a constant of integration to the integral in the integrating factor and show that the solution you get in the end is the same as what we got above.

An advice: Do not try to remember the formula itself, that is way too hard. It is easier to remember the process and repeat it.

Since we cannot always evaluate the integrals in closed form, it is useful to know how to write the solution in definite integral form. A definite integral is something that you can plug into a computer or a calculator. Suppose we are given

y′ + p(x)y = f(x), y(x0) = y0.

Look at the solution and write the integrals as definite integrals.

|----------∫-----(∫--x-∫---------------)---| | - xx0p(s)ds xt0p(s)ds | | y(x) = e x e f(t) dt + y0 .| --------------------0----------------------
(1.4)

You should be careful to properly use dummy variables here. If you now plug such a formula into a computer or a calculator, it will be happy to give you numerical answers.

Exercise 1.4.2: Check that y(x0) = y0 in formula (1.4).

Exercise 1.4.3: Write the solution of the following problem as a definite integral, but try to simplify as far as you can. You will not be able to find the solution in closed form.

 ′ x2-x y + y = e , y(0) = 10.

Remark 1.4.1: Before we move on, we should note some interesting properties of linear equations. First, for the linear initial value problem y′ + p(x)y = f(x) , y(x0) = y0 , there is always an explicit formula (1.4) for the solution. Second, it follows from the formula (1.4) that if p(x) and f (x) are continuous on some interval (a,b) , then the solution y(x) exists and is differentiable on (a,b) . Compare with the simple nonlinear example we have seen previously,  ′ 2 y = y , and compare to Theorem 1.2.1.

Example 1.4.2: Let us discuss a common simple application of linear equations. This type of problem is used often in real life. For example, linear equations are used in figuring out the concentration of chemicals in bodies of water (rivers and lakes).

PIC

A 100 liter tank contains 10 kilograms of salt dissolved in 60 liters of water. Solution of water and salt (brine) with concentration of 0.1 kilograms per liter is flowing in at the rate of 5 liters a minute. The solution in the tank is well stirred and flows out at a rate of 3 liters a minute. How much salt is in the tank when the tank is full?

Let us come up with the equation. Let x denote the kilograms of salt in the tank, let t denote the time in minutes. For a small change Δt in time, the change in x (denoted Δx ) is approximately

Δx ≈ (rate in × concentration in)Δt - (rate out × concentration out)Δt.

Dividing through by Δt and taking the limit Δt → 0 we see that

dx ---= (rate in × concentration in) - (rate out × concentration out). dt

In our example, we have

 rate in = 5, concentration in = 0.1, rate out = 3, x x concentration out = -------= ------------. volume 60 + (5 - 3)t
Our equation is, therefore,
dx ( x ) --- = (5 × 0.1) - 3------- . dt 6 0 + 2t

Or in the form (1.3)

dx- ---3--- dt + 60 + 2tx = 0.5.

Let us solve. The integrating factor is

 (∫ 3 ) (3 ) r(t) = exp ------dt = exp -ln(60 + 2t) = (60 + 2t)3∕2. 60 + 2t 2

We multiply both sides of the equation to get

 3∕2dx- 3∕2--3---- 3∕2 (60 + 2t) dt + (60 + 2t) 60 + 2t x = 0.5(60 + 2t) , d [ 3∕2 ] 3∕2 -- (60 + 2t) x = 0.5(60 + 2t) , dt ∫ (60 + 2t)3∕2x = 0.5(60 + 2t)3∕2dt + C, ∫ (60 + 2t)3∕2 x = (60 + 2t)-3∕2 -----------dt + C (60 + 2t)-3∕2, 2 -3∕2-1- 5∕2 -3∕2 x = (60 + 2t) 10(60 + 2t) + C (60 + 2t) , 60 + 2t x = -------+ C(60 + 2t)-3∕2. 10

We need to find C . We know that at t = 0 , x = 1 0 . So

 60- -3∕2 -3∕2 10 = x(0) = 10 + C(60) = 6 + C(60) ,

or

 3∕2 C = 4(60 ) ≈ 1859.03.

We are interested in x when the tank is full. So we note that the tank is full when 60 + 2t = 100 , or when t = 20 . So

x(20) = 60-+-40-+ C(60 + 40)-3∕2 ≈ 10 + 1859.03(100)-3∕2 ≈ 11.86. 10

The concentration at the end is approximately 0.1186 kg/liter and we started with 1/6 or 0.167 kg/liter.

1.4.1 Exercises

In the exercises, feel free to leave answer as a definite integral if a closed form solution cannot be found. If you can find a closed form solution, you should give that.

Exercise 1.4.4: Solve  ′ y + xy = x .

Exercise 1.4.5: Solve  ′ x y + 6y = e .

Exercise 1.4.6: Solve y′ + 3x2y = sin (x)e-x3 , with y(0) = 1 .

Exercise 1.4.7: Solve y′ + cos(x)y = co s(x) .

Exercise 1.4.8: Solve -1-- ′ x2+1y + xy = 3 , with y(0) = 0 .

Exercise 1.4.9: Suppose there are two lakes located on a stream. Clean water flows into the first lake, then the water from the first lake flows into the second lake, and then water from the second lake flows further downstream. The in and out flow from each lake is 500 liters per hour. The first lake contains 100 thousand liters of water and the second lake contains 200 thousand liters of water. A truck with 500 kg of toxic substance crashes into the first lake. Assume that the water is being continually mixed perfectly by the stream. a) Find the concentration of toxic substance as a function of time in both lakes. b) When will the concentration in the first lake be below 0.001 kg per liter? c) When will the concentration in the second lake be maximal?

Exercise 1.4.10: Newton’s law of cooling states that dx= - k(x - A ) dt where x is the temperature, t is time, A is the ambient temperature, and k > 0 is a constant. Suppose that A = A 0cos(ωt) for some constants A0 and ω . That is, the ambient temperature oscillates (for example night and day temperatures). a) Find the general solution. b) In the long term, will the initial conditions make much of a difference? Why or why not?

Exercise 1.4.11: Initially 5 grams of salt are dissolved in 20 liters of water. Brine with concentration of salt 2 grams of salt per liter is added at a rate of 3 liters a minute. The tank is mixed well and is drained at 3 liters a minute. How long does the process have to continue until there are 20 grams of salt in the tank?

Exercise 1.4.12: Initially a tank contains 10 liters of pure water. Brine of unknown (but constant) concentration of salt is flowing in at 1 liter per minute. The water is mixed well and drained at 1 liter per minute. In 20 minutes there are 15 grams of salt in the tank. What is the concentration of salt in the incoming brine?

Exercise 1.4.101: Solve y′ + 3x 2y = x2 .

Exercise 1.4.102: Solve  ′ y + 2 sin (2x )y = 2 sin(2x) ,  π y( ∕2) = 3 .

Exercise 1.4.103: Suppose a water tank is being pumped out at 3 L/min. The water tank starts at 10 L of clean water. Water with toxic substance is flowing into the tank at 2 L/min, with concentration 2 0t g/L at time t . When the tank is half empty, how many grams of toxic substance are in the tank (assuming perfect mixing)?

Exercise 1.4.104: Suppose we have bacteria on a plate and suppose that we are slowly adding a toxic substance such that the rate of growth is slowing down. That is, suppose that dP -dt = (2 - 0.1t)P . If P(0) = 1 000 , find the population at t = 5 .