First-Order Linear Differential Equations
A first-order linear differential equation can be written as y′ + p(x)y = q(x). To solve it, multiply both sides by the integrating factor μ(x) = e^(∫p(x) dx). The left side becomes the derivative of μy, so you integrate both sides, then divide by μ to get y.
Before this lesson: Classifying Differential Equations, Integration by Parts and U-Substitution
The idea: make the left side a product-rule derivative
Look at the left side of x²y′ + 2xy = 4x³. It is exactly the derivative of x²y, because the product rule gives (x²y)′ = x²y′ + 2xy. So the equation says (x²y)′ = 4x³, and you can integrate both sides at once.
Most linear equations don’t come in that lucky shape. The integrating factor is a function μ(x) that you multiply by to create it. After the multiplication, the left side is the derivative of μy, and the problem turns into one ordinary integral.
The method works for every first-order linear equation, including the many that are not separable, such as dy/dx = x + y. That is what makes it the main tool of this unit.
First-order linear differential equations: the formula
Start from standard form, where the coefficient of y′ is 1:
y' + p(x)\,y = q(x)
Here is where the integrating factor comes from.
\mu y' + \mu\,p(x)\,y = \mu\,q(x)
Multiply every term by an unknown function μ(x).
\mu' = \mu\,p(x)
Choose μ so this holds. Then the left side is μy′ + μ′y, which is (μy)′ by the product rule.
\mu(x) = e^{\int p(x)\,dx}Solve μ′/μ = p(x), a separable differential equation. Any one solution works, so leave out the constant.
(\mu y)' = \mu\,q(x)
Rewrite the left side as one derivative.
\mu y = \int \mu\,q(x)\,dx + C
Integrate both sides.
y = \dfrac{1}{\mu(x)}\left(\int \mu(x)\,q(x)\,dx + C\right)Divide both sides by μ.
How to solve a first-order linear differential equation
- Write the equation in standard form y′ + p(x)y = q(x). Divide by the coefficient of y′ if it isn’t 1.
- Find the integrating factor μ = e^(∫p(x) dx), with no constant.
- Multiply every term by μ. Check that the left side is (μy)′.
- Integrate both sides, and add C on the right.
- Divide by μ to solve for y. Divide the C term too.
- If there is an initial condition, substitute it to find C.
The answer usually has two parts. The term C/μ solves the homogeneous equation y′ + py = 0, and the rest is one particular solution of the full equation.
First-order linear differential equation examples
Example 1: Constant coefficient
Solve y′ + 2y = 6 with y(0) = 5.
p(x) = 2,\; q(x) = 6
The equation is already in standard form.
\mu = e^{\int 2\,dx} = e^{2x}Find the integrating factor, with no constant.
e^{2x}y' + 2e^{2x}y = 6e^{2x}Multiply every term by e²ˣ.
(e^{2x}y)' = 6e^{2x}The left side is the derivative of e²ˣy by the product rule.
e^{2x}y = 3e^{2x} + CIntegrate both sides.
y = 3 + Ce^{-2x}Divide every term by e²ˣ.
5 = 3 + Ce^{0}Substitute x = 0 and y = 5.
C = 2
Use e⁰ = 1, then subtract 3 from both sides.
Answer: y = 3 + 2e^(−2x). As x grows, the e^(−2x) term dies out and y approaches 3.
Example 2: Integrating factor with a logarithm
Solve y′ + (2/x)y = 4x for positive x, with y(1) = 3.
p(x) = \dfrac{2}{x},\; q(x) = 4xThe equation is already in standard form.
\int \dfrac{2}{x}\,dx = 2\ln xIntegrate p. Since x is positive, no absolute value is needed.
\mu = e^{2\ln x} = e^{\ln x^2}Move the 2 inside the log with the power rule (see properties of logarithms).
\mu = x^2
Use e^(ln a) = a.
x^2y' + 2xy = 4x^3
Multiply every term by x².
(x^2y)' = 4x^3
The left side is the derivative of x²y.
x^2y = x^4 + C
Integrate both sides.
y = x^2 + \dfrac{C}{x^2}Divide every term by x².
3 = 1 + C
Substitute x = 1 and y = 3.
C = 2
Subtract 1 from both sides.
Answer: y = x² + 2/x².
Example 3: Put it in standard form first
Find the general solution of xy′ + y = x cos x for positive x.
y' + \dfrac{1}{x}\,y = \cos xDivide every term by x to get standard form.
\mu = e^{\int (1/x)\,dx} = e^{\ln x} = xFind the integrating factor.
xy' + y = x\cos x
Multiply every term by x. This is the original equation: its left side was already a derivative.
(xy)' = x\cos x
Rewrite the left side as the derivative of xy.
xy = \int x\cos x\,dx
Integrate both sides.
xy = x\sin x - \int \sin x\,dx
Use integration by parts with u = x and dv = cos x dx.
xy = x\sin x + \cos x + C
Integrate sin x and add C.
y = \sin x + \dfrac{\cos x}{x} + \dfrac{C}{x}Divide every term by x.
Answer: y = sin x + (cos x)/x + C/x.
Example 4: A negative p(x)
Solve y′ − 2xy = x with y(0) = 1.
p(x) = -2x,\; q(x) = x
Standard form. The minus sign belongs to p(x).
\mu = e^{\int -2x\,dx} = e^{-x^2}Find the integrating factor.
(e^{-x^2}y)' = xe^{-x^2}Multiply every term by e^(−x²) and rewrite the left side with the product rule.
e^{-x^2}y = \int xe^{-x^2}\,dxIntegrate both sides.
e^{-x^2}y = -\tfrac{1}{2}e^{-x^2} + CUse u-substitution with u = −x², so x dx = −du/2.
y = -\tfrac{1}{2} + Ce^{x^2}Multiply every term by e^(x²).
1 = -\tfrac{1}{2} + Ce^{0}Substitute x = 0 and y = 1.
C = \tfrac{3}{2}Use e⁰ = 1, then add 1/2 to both sides.
Answer: y = −1/2 + (3/2)e^(x²). Check: y′ = 3xe^(x²), and 2xy + x = −x + 3xe^(x²) + x = 3xe^(x²).
Example 5: A falling skydiver (word problem)
A skydiver jumps from a plane. With air resistance, her velocity v (in m/s) after t seconds follows dv/dt = 9.8 − 0.2v, with v(0) = 0. Find v(t), her velocity after 5 seconds and her terminal velocity.
v' + 0.2v = 9.8
Add 0.2v to both sides to get standard form.
\mu = e^{\int 0.2\,dt} = e^{0.2t}Find the integrating factor.
(e^{0.2t}v)' = 9.8e^{0.2t}Multiply every term by e^(0.2t) and rewrite the left side.
e^{0.2t}v = 49e^{0.2t} + CIntegrate both sides: 9.8 ÷ 0.2 = 49.
v = 49 + Ce^{-0.2t}Divide every term by e^(0.2t).
0 = 49 + C
Substitute t = 0 and v = 0.
C = -49
Subtract 49 from both sides.
v = 49\left(1 - e^{-0.2t}\right)Factor out 49.
v(5) = 49\left(1 - e^{-1}\right) \approx 30.97Substitute t = 5 and use a calculator.
\lim_{t \to \infty} v(t) = 49As t grows, e^(−0.2t) approaches 0.
Answer: v = 49(1 − e^(−0.2t)). After 5 seconds she falls at about 31.0 m/s, and her terminal velocity is 49 m/s.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Finding μ before writing standard form | For xy' + 2y = x^3, using \mu = e^{\int 2\,dx} | Divide by x first: y' + \tfrac{2}{x}y = x^2, so \mu = x^2. |
| Dropping the sign of p(x) | For y' - 2xy = x, using \mu = e^{x^2} | Here p(x) = -2x, so \mu = e^{-x^2}. |
| Multiplying only the left side by μ | Writing (e^{2x}y)' = 6 | Multiply every term: (e^{2x}y)' = 6e^{2x}. |
| Adding C after dividing by μ | Writing y = 3 + C | Add C when you integrate, then divide it by μ too: y = 3 + Ce^{-2x}. |
| Simplifying e^{2\ln x} as 2x | Writing \mu = 2x | e^{2\ln x} = e^{\ln x^2} = x^2. |
| Putting a constant in μ | Using \mu = e^{2x + K} and carrying K along | Any one integrating factor works, so take K = 0. |
Related methods
When the equation is also separable
If p and q are both constants, as in Example 1, the equation is also separable, so separation of variables gives the same answer. The integrating factor works whether or not the equation separates.
Growth, decay and cooling
Newton’s law of cooling, dT/dt = −k(T − Tₐ), is first-order linear: it is T′ + kT = kTₐ. So is the model in exponential models with differential equations. When the surrounding temperature or the input changes with time, separation no longer works but the integrating factor still does.
Other first-order methods
Some nonlinear first-order equations become linear after a substitution; Bernoulli Equations uses that trick. Others are exact, which Exact Differential Equations covers.
Practice problems
- Find the general solution of y′ + 3y = 12.
- Solve y′ − 4y = 8 with y(0) = 1.
- Find the general solution of y′ + y = eˣ.
- Find the general solution of y′ + (1/x)y = 3x for positive x.
- Solve xy′ + 2y = 5x³ with y(1) = 2, for positive x.
- Solve y′ + 2xy = 2x with y(0) = 4.
- Find the general solution of y′ − y = x.
- Find the general solution of y′ + (cot x)y = cos x for x between 0 and π.
- A cup of tea at 90°C cools in a 20°C room according to dT/dt = −0.1(T − 20), where t is in minutes. Find T(t) and the temperature after 10 minutes.
- A circuit with inductance 2 henries, resistance 10 ohms and a 40-volt battery has current i (in amps) that follows 2 di/dt + 10i = 40, with i(0) = 0. Find i(t) and the current after 0.2 seconds.
Show answers
1.
\mu = e^{\int 3\,dx} = e^{3x}Standard form, p = 3. Find the integrating factor.
(e^{3x}y)' = 12e^{3x}Multiply by e³ˣ and rewrite the left side.
e^{3x}y = 4e^{3x} + CIntegrate both sides: 12 ÷ 3 = 4.
y = 4 + Ce^{-3x}Divide every term by e³ˣ.
Answer: y = 4 + Ce^(−3x)
2.
\mu = e^{\int -4\,dx} = e^{-4x}Standard form, p = −4.
(e^{-4x}y)' = 8e^{-4x}Multiply by e^(−4x) and rewrite the left side.
e^{-4x}y = -2e^{-4x} + CIntegrate: 8 ÷ (−4) = −2.
y = -2 + Ce^{4x}Multiply every term by e⁴ˣ.
1 = -2 + C
Substitute x = 0 and y = 1.
C = 3
Add 2 to both sides.
Answer: y = −2 + 3e^(4x)
3.
\mu = e^{\int 1\,dx} = e^{x}Standard form, p = 1.
(e^{x}y)' = e^{x}e^{x} = e^{2x}Multiply by eˣ; add the exponents (see exponent rules).
e^{x}y = \tfrac{1}{2}e^{2x} + CIntegrate both sides.
y = \tfrac{1}{2}e^{x} + Ce^{-x}Divide every term by eˣ.
Answer: y = ½eˣ + Ce^(−x)
4.
\mu = e^{\ln x} = xp = 1/x, and ∫(1/x) dx = ln x for positive x.
(xy)' = 3x^2
Multiply every term by x and rewrite the left side.
xy = x^3 + C
Integrate both sides.
y = x^2 + \dfrac{C}{x}Divide every term by x.
Answer: y = x² + C/x
5.
y' + \dfrac{2}{x}\,y = 5x^2Divide every term by x to get standard form.
\mu = e^{2\ln x} = x^2Find the integrating factor.
(x^2y)' = 5x^4
Multiply every term by x² and rewrite the left side.
x^2y = x^5 + C
Integrate both sides.
y = x^3 + \dfrac{C}{x^2}Divide every term by x².
2 = 1 + C
Substitute x = 1 and y = 2.
C = 1
Subtract 1 from both sides.
Answer: y = x³ + 1/x²
6.
\mu = e^{\int 2x\,dx} = e^{x^2}Standard form, p = 2x.
(e^{x^2}y)' = 2xe^{x^2}Multiply every term by e^(x²) and rewrite the left side.
e^{x^2}y = e^{x^2} + CIntegrate with u = x², du = 2x dx.
y = 1 + Ce^{-x^2}Divide every term by e^(x²).
4 = 1 + C
Substitute x = 0 and y = 4.
C = 3
Subtract 1 from both sides.
Answer: y = 1 + 3e^(−x²)
7.
\mu = e^{\int -1\,dx} = e^{-x}Standard form, p = −1.
(e^{-x}y)' = xe^{-x}Multiply every term by e^(−x) and rewrite the left side.
e^{-x}y = -xe^{-x} + \int e^{-x}\,dxIntegrate by parts with u = x and dv = e^(−x) dx.
e^{-x}y = -xe^{-x} - e^{-x} + CIntegrate e^(−x).
y = -x - 1 + Ce^{x}Multiply every term by eˣ.
Answer: y = −x − 1 + Ceˣ
8.
\int \cot x\,dx = \ln(\sin x)
p = cot x = cos x/sin x; sin x is positive on (0, π).
\mu = e^{\ln(\sin x)} = \sin xFind the integrating factor.
(y\sin x)' = \sin x\cos x
Multiply every term by sin x and rewrite the left side.
y\sin x = \tfrac{1}{2}\sin^2 x + CIntegrate with u = sin x, du = cos x dx.
y = \tfrac{1}{2}\sin x + \dfrac{C}{\sin x}Divide every term by sin x.
Answer: y = ½ sin x + C/sin x
9.
T' + 0.1T = 2
Distribute: −0.1(T − 20) = −0.1T + 2. Then add 0.1T to both sides.
\mu = e^{0.1t}Find the integrating factor.
(e^{0.1t}T)' = 2e^{0.1t}Multiply every term by e^(0.1t) and rewrite the left side.
e^{0.1t}T = 20e^{0.1t} + CIntegrate: 2 ÷ 0.1 = 20.
T = 20 + Ce^{-0.1t}Divide every term by e^(0.1t).
90 = 20 + C
Substitute t = 0 and T = 90.
C = 70
Subtract 20 from both sides.
T(10) = 20 + 70e^{-1} \approx 45.75Substitute t = 10 and use a calculator.
Answer: T = 20 + 70e^(−0.1t), about 45.8°C after 10 minutes
10.
i' + 5i = 20
Divide every term by 2 to get standard form.
\mu = e^{5t}Find the integrating factor.
(e^{5t}i)' = 20e^{5t}Multiply every term by e^(5t) and rewrite the left side.
e^{5t}i = 4e^{5t} + CIntegrate: 20 ÷ 5 = 4.
i = 4 + Ce^{-5t}Divide every term by e^(5t).
0 = 4 + C
Substitute t = 0 and i = 0.
C = -4
Subtract 4 from both sides.
i(0.2) = 4\left(1 - e^{-1}\right) \approx 2.53Substitute t = 0.2 into i = 4(1 − e^(−5t)).
Answer: i = 4(1 − e^(−5t)), about 2.53 amps after 0.2 seconds
First-order linear differential equations FAQ
What is an integrating factor?
It is a function μ(x) that you multiply a differential equation by so that one side becomes an exact derivative. For y′ + p(x)y = q(x), the integrating factor is μ = e^(∫p(x) dx).
How do you know if a first-order differential equation is linear?
It is linear if you can write it as y′ + p(x)y = q(x), with y and y′ only to the first power and p and q depending only on x. Equations with terms like y², yy′ or sin y are not linear.
Why don’t you add a constant to the integrating factor?
A constant K in the exponent multiplies μ by e^K, and that factor cancels when you divide by μ at the end. Any one integrating factor gives the same general solution.
Can an equation be both separable and linear?
Yes. y′ + 2y = 6 is both, because 6 − 2y is a function of y alone. Either method works, and both give y = 3 + Ce^(−2x).
Summary
- Standard form: y′ + p(x)y = q(x), with the coefficient of y′ equal to 1.
- Integrating factor: μ = e^(∫p(x) dx), with no constant.
- Multiplying by μ makes the left side (μy)′, by the product rule.
- Then μy = ∫μq dx + C, and y = (∫μq dx + C)/μ.
- Add C when you integrate, and divide it by μ along with everything else.
- Use the initial condition last, to find C.
Previous lesson: Classifying Differential Equations
Next lesson: Exact Differential Equations
Back to the Differential Equations Index