Linear Differential Equations of the First-Order

The linear first-order equation y' + P(x)y = Q(x) is the one family in this chapter that can always be solved, with no cleverness required. Multiplying by the integrating factor e P d x turns the left-hand side into the derivative of a single product, after which one integration finishes the problem.

Quick Reference

Item Statement
General linear form a ( x ) d y d x + b ( x ) y ( x ) = f ( x )
Standard form d y d x + P ( x ) y ( x ) = Q ( x ) , with P = b / a and Q = f / a
Integrating factor I ( x ) = e P ( x ) d x
Key identity I(x)\left[y' + P(x)y\right] = \dfrac{d}{dx}\left[I(x)y(x)\right]
After multiplying d d x [ I ( x ) y ( x ) ] = I ( x ) Q ( x )
Integrated form I ( x ) y ( x ) = I ( x ) Q ( x ) d x + c
General solution y ( x ) = e P d x [ Q ( x ) e P d x d x + c ]
Homogeneous solution y h = c e P ( x ) d x

The Standard Form

A linear differential equation of first-order is one of the form

a(x)\frac{dy}{dx} + b(x)y(x) = f(x) \tag{9}

where a ( x ) , b ( x ) , and f ( x ) are functions defined on an interval ( α , β ) . If a ( x ) 0 on ( α , β ) , we can divide both sides of (9) to obtain the standard form

\frac{dy}{dx} + P(x)\,y(x) = Q(x) , \tag{10}

where P ( x ) = b ( x ) / a ( x ) and Q ( x ) = f ( x ) / a ( x ) .

This equation is first-order because the first derivative of y is the highest derivative occurring, and it is linear because y and its derivative both have exponent one and are not multiplied together. The coefficient P and the forcing term Q may be arbitrary functions of x ; nothing about them affects linearity.

The requirement a ( x ) 0 is not a technicality. Points where a vanishes are called singular points, and the division that produces standard form fails there. In x y' + y = x^2, dividing by x gives P ( x ) = 1 / x , which blows up at the origin, and solutions can behave badly there. Always note the interval on which the standard form is valid.

Method 1: The Integrating Factor

To solve this equation, we look for an integrating function I ( x ) such that

I(x)\left[\frac{dy(x)}{dx} + P(x)\,y(x)\right] = \frac{d}{dx}\left[I(x)\,y(x)\right] \tag{11}

recalling the product rule \left(uv\right)' = u'v + uv'.

The idea is worth pausing on. The left side of the standard form is a sum of two unrelated-looking terms. Equation (11) asks for a multiplier that fuses them into a single derivative, so that the equation can be integrated in one step.

If a suitable function I ( x ) can be found, the differential equation can be written as

d d x [ I ( x ) y ( x ) ] = I ( x ) Q ( x )

and integrating both sides yields

I(x)\,y(x) = \int I(x)\,Q(x)\,dx + c \tag{12}

where c is an arbitrary constant.

To find a suitable I ( x ) , expand both sides of Equation (11):

I ( x ) d y d x + I ( x ) P ( x ) y ( x ) = I ( x ) d y d x + y ( x ) d I d x d d x [ I ( x ) y ( x ) ]

The term I ( x ) d y d x cancels from both sides, and dividing what remains by y ( x ) leaves a condition on I alone:

d I d x = I ( x ) P ( x )

This is a separable equation for I . Writing it as

d I I = P ( x ) d x

and integrating, we obtain

ln | I ( x ) | = P ( x ) d x + k

where k is a constant. Because one integrating factor suffices, we may set k = 0 , or any other value we like. Thus

I(x) = \exp\left(\int P(x)\,dx + k\right) = \underbrace{\exp(k)}_{=\,1 \text{ if } k\,=\,0}\ \exp\left(\int P(x)\,dx\right) \tag{13}

Because 1 / I ( x ) = exp ( P ( x ) d x ) , combining Equations (12) and (13) gives the general solution of Equation (10):

y ( x ) = e P ( x ) d x [ Q ( x ) e P ( x ) d x d x + c ]

In words: multiply the forcing term Q by the integrating factor, integrate, add an arbitrary constant, then divide the whole thing by the integrating factor.

Practical advice. Do not memorize the boxed formula. Memorize the procedure: put the equation in standard form, compute I = e P d x , multiply through, recognize the left side as \left(Iy\right)', integrate, divide by I . Executing the steps is faster and far less error-prone than substituting into the formula.

Method 2: Solve the Homogeneous Equation First, Then Vary the Constant

There is a second route that generalizes to higher order equations, where it is known as variation of parameters.

First find the solution of the homogeneous equation, that is, the case Q ( x ) 0 , and call it y h :

d y h d x + P ( x ) y h = 0 d y h y h = P ( x ) d x

Integrating both sides,

ln | y h | = P ( x ) d x + C

where C is a constant. Taking exponentials of both sides,

y h = c e P ( x ) d x

where c = e C if y h 0 and c = e C if y h < 0 .

The second step is the clever one: replace the constant c by an unknown function c ( x ) , substitute y = c ( x ) y h into the full equation, and solve the resulting equation for c ( x ) . The terms involving c ( x ) itself always cancel, precisely because y h solves the homogeneous equation, leaving a simple equation for c'(x).

Worked Examples

Find the general solution of the equation

d y d x ( cot x ) y = x sin x .
Solution

We use Method 2. First find the solution of the homogeneous equation:

d y d x ( cot x ) y = 0 d y y = cos x sin x d x

Integrating both sides, and writing the constant as ln c for convenience,

ln | y | = ln | sin x | + ln c or y = c sin x .

Now vary the constant. Let y = c ( x ) sin x . Then by the product rule,

\frac{dy}{dx} = y'(x) = c'(x)\sin x + c(x)\cos x .

Substitute into the original equation:

c'(x)\sin x + c(x)\cos x - \frac{\cos x}{\sin x}\,c(x)\sin x = x \sin x

The second and third terms on the left cancel exactly, since cos x sin x sin x = cos x . This cancellation is guaranteed, because sin x solves the homogeneous equation. What remains is

c'(x)\sin x = x\sin x \quad \Longrightarrow \quad c'(x) = x \quad \Longrightarrow \quad c(x) = \frac{1}{2}x^2 + k .

Thus

y ( x ) = 1 2 x 2 sin x + k sin x .

Note the structure of the answer: a particular solution 1 2 x 2 sin x plus an arbitrary multiple of the homogeneous solution sin x . Every linear equation's general solution has this shape.

Solve d y d x + 3 y = e 2 x using the integrating factor.

Solution

The equation is already in standard form with P ( x ) = 3 and Q ( x ) = e 2 x . The integrating factor is

I ( x ) = e 3 d x = e 3 x .

Multiplying through by e 3 x ,

e 3 x d y d x + 3 e 3 x y = e 3 x e 2 x = e 5 x .

The left side is exactly d d x ( e 3 x y ) , which is the whole point of the factor. So

d d x ( e 3 x y ) = e 5 x e 3 x y = 1 5 e 5 x + c .

Dividing by e 3 x ,

y = 1 5 e 2 x + c e 3 x .

Again a particular solution plus a multiple of the homogeneous solution e 3 x .

Solve the initial value problem x d y d x + 2 y = 4 x 2 , y ( 1 ) = 3 , and state the interval of validity.

Solution

First put the equation in standard form by dividing by x , which requires x 0 :

d y d x + 2 x y = 4 x .

The integrating factor is

I ( x ) = e ( 2 / x ) d x = e 2 ln | x | = x 2 .

Multiplying through,

x 2 d y d x + 2 x y = 4 x 3 d d x ( x 2 y ) = 4 x 3 .

Integrating,

x 2 y = x 4 + c y = x 2 + c x 2 .

Applying y ( 1 ) = 3 gives 1 + c = 3 , so c = 2 and

y = x 2 + 2 x 2 .

The initial point is x = 1 > 0 , and the solution is undefined at x = 0 , so the interval of validity is x > 0 . Note that the original equation xy' + 2y = 4x^2 looks perfectly well behaved at the origin; the trouble appears only after dividing by x , and it is real.

Solve d y d x y = x , and identify the homogeneous and particular parts.

Solution

Here P ( x ) = 1 and Q ( x ) = x , so I ( x ) = e x . Multiplying,

d d x ( e x y ) = x e x .

Integrate the right side by parts, with u = x and d v = e x d x , so d u = d x and v = e x :

x e x d x = x e x + e x d x = x e x e x .

Therefore

e x y = x e x e x + c y = x 1 + c e x .

The homogeneous part is c e x and the particular part is x 1 . You can check the latter directly: (-x-1)' - (-x-1) = -1 + x + 1 = x.

Exercises

Solve y' + 2xy = x.

Solution

Here P = 2 x , so I = e x 2 . Multiplying,

d d x ( e x 2 y ) = x e x 2 .

Integrating with the substitution u = x 2 ,

e x 2 y = 1 2 e x 2 + c y = 1 2 + c e x 2 .

Note that y = 1 2 is an equilibrium solution, obtained by taking c = 0 .

Solve the initial value problem y' + y\tan x = \sin 2x, y ( 0 ) = 1 .

Solution

The integrating factor is

I = e tan x d x = e ln | cos x | = sec x .

Multiplying and using sin 2 x = 2 sin x cos x ,

d d x ( y sec x ) = sec x 2 sin x cos x = 2 sin x .

Integrating, y sec x = 2 cos x + c , so

y = 2 cos 2 x + c cos x .

Applying y ( 0 ) = 1 gives 2 + c = 1 , so c = 3 and

y = 3 cos x 2 cos 2 x .

The interval of validity is π / 2 < x < π / 2 , since tan x blows up at the endpoints.

A tank holds 100 liters of pure water. Brine containing 2 grams of salt per liter flows in at 5 liters per minute, and the well-stirred mixture flows out at the same rate. Find the amount of salt S ( t ) at time t .

Solution

Salt enters at 2 × 5 = 10 grams per minute. The concentration in the tank is S / 100 grams per liter, so salt leaves at 5 S 100 = S 20 grams per minute. Therefore

d S d t = 10 S 20 d S d t + 1 20 S = 10 ,

a linear equation with I = e t / 20 . Multiplying,

d d t ( S e t / 20 ) = 10 e t / 20 S e t / 20 = 200 e t / 20 + c .

So S = 200 + c e t / 20 . Since the tank starts with pure water, S ( 0 ) = 0 gives c = 200 , and

S ( t ) = 200 ( 1 e t / 20 ) .

As t , S 200 grams, which is the tank at the inflow concentration of 2 grams per liter, exactly as expected.

Frequently Asked Questions

What makes a first-order equation linear?

It can be written as y' + P(x)y = Q(x): the unknown y and its derivative each appear to the first power, are not multiplied by each other, and are not inside any nonlinear function. The coefficients P and Q may be any functions of x whatsoever. Terms like y 2 , yy', y , or sin y destroy linearity.


Why does multiplying by e P d x work?

Because that factor is designed so that I' = IP. With that property the product rule gives

\left(Iy\right)' = Iy' + I'y = Iy' + IPy = I\left(y' + Py\right) ,

which is exactly I times the left side of the standard form. So multiplying collapses two terms into one derivative, and the equation becomes directly integrable.


Do I need the constant of integration inside the integrating factor?

No. Including k would multiply I by the constant e k , which then divides out at the end. Since any one integrating factor suffices, always take k = 0 and keep the expression clean.


Should I use absolute values when P d x produces a logarithm?

You can drop them in practice. If P d x = 2 ln | x | , then I = e 2 ln | x | = | x | 2 = x 2 , so the absolute value disappears on its own for even powers. For odd powers, the sign difference amounts to multiplying I by 1 , which is another valid integrating factor. Just be sure to work on an interval that avoids the singular point.


Which method should I use, the integrating factor or varying the constant?

The integrating factor is faster and more mechanical for first-order problems, so use it by default. Method 2 is worth understanding anyway, because it is the first appearance of variation of parameters, which is the standard tool for higher order linear equations and for systems where no integrating factor exists.


Why does the general solution always split into two pieces?

Because the equation is linear. If y p is any particular solution and y h solves the homogeneous equation, then y p + c y h solves the full equation for every c , and every solution has that form. So the answer is always "one particular solution plus the general homogeneous solution". This structural fact carries through the entire rest of the book.


What if the equation is linear in x rather than in y ?

Then swap the roles of the variables. The equation d y d x = 1 x + y 2 is nonlinear in y , but inverting gives d x d y = x + y 2 , that is, d x d y x = y 2 , which is linear in x with integrating factor e y . Always check this when an equation looks hopeless in its given orientation.