Differential Equations, Topic 4 of 10

First-Order
Linear ODEs

The standard form y′ + P(x)y = Q(x) describes everything from cooling coffee to charging capacitors. One elegant trick, the integrating factor, solves them all.

Standard form Integrating factor derivation 12 worked examples Real-world applications
Share this page

§ 01What Is a First-Order Linear ODE?

A first-order ODE is linear if y and y′ each appear to the first power and are not multiplied together. Every such equation can be written in one of two equivalent standard forms.

The most general first-order linear ODE is:

Standard Form
y′ + P(x)y = Q(x)

Here P(x) and Q(x) are any continuous functions of x. The equation is linear because y and y′ appear only to the first power and are never multiplied together: no y², no y·y′, no sin(y). That linearity is what makes a systematic solution method possible.

If you are handed an equation that looks different, the first job is always to rewrite it in standard form. For instance:

Rewriting into standard form
xy′ + 3y = x²    ÷x    →    y′ + (3/x)y = x

y′ = 2y + ex    →    y′ − 2y = ex

Once in standard form, we can read off P(x) and Q(x) immediately:

  • First example above: P(x) = 3/x,   Q(x) = x
  • Second example above: P(x) = −2,   Q(x) = ex
What makes it solvable? A separable equation can be solved by separating variables — but only when Q(x) = 0 or when the right-hand side factors neatly. The integrating factor method works for any first-order linear ODE, regardless of what P(x) and Q(x) look like, as long as they are continuous.

Linear vs. Non-Linear — Quick Tests

Before applying the method, check that the equation is genuinely linear. An ODE is non-linear if it contains any of: y², y³, √y, 1/y, sin(y), y·y′, or (y′)². These require different techniques entirely.

⚠ Not first-order linear y′ + y² = x   (contains y²)  —  this is a Bernoulli equation.
y′ = sin(y)   (contains sin(y))  —  non-linear, no closed-form solution in general.
y·y′ = x   (y and y′ multiplied)  —  non-linear (though this particular one is separable).

§ 02The Integrating Factor — Full Derivation

The integrating factor is not a formula to memorise blindly. It emerges from a single clever observation about the product rule.

Start with the standard form and ask: can we multiply both sides by some function μ(x) so that the left-hand side becomes a perfect derivative?

Goal
μy′ + μP(x)y  =  d/dx[μy]

Expand the right-hand side using the product rule:

Product rule expansion
d/dx[μy] = μ′y + μy′

Matching the two expressions: we need μP(x)y = μ′y, which means μ′ = μP(x). This is a separable ODE for μ:

Derivation Finding the integrating factor μ(x)
dμ/dx = μP(x)
separable ODE for μ
dμ/μ = P(x) dx
separate variables
ln|μ| = ∫P(x) dx
integrate both sides
μ(x) = e∫P(x)dx
exponentiate; absorb ± into the constant (we only need one μ)

Now that we have μ, multiply the original equation through by it:

Using μ to solve Completing the solution
μy′ + μP(x)y = μQ(x)
multiply both sides by μ
d/dx[μy] = μQ(x)
left side is now a perfect derivative
μy = ∫μQ(x) dx + C
integrate both sides with respect to x
y = (1/μ) [ ∫μQ(x) dx + C ]
divide both sides by μ to isolate y

That last line is the general solution formula. In practice, you never memorise it, you re-derive it from the μ step every time, which is fast once the method is internalized.

Why this always works The magic is that μ transforms the left-hand side from two separate terms (μy′ and μPy) into a single derivative d/dx[μy]. Once the left side is a perfect derivative, both sides can be integrated directly. The integration on the right produces the general solution.

§ 03The 4-Step Method

Every first-order linear ODE is solved in exactly four steps. Commit these to memory and you can solve any equation of this type.

The Integrating Factor Method — 4 Steps

  1. Write the equation in standard form. Divide through by the coefficient of y′ if necessary, so the equation reads y′ + P(x)y = Q(x). Read off P(x) and Q(x).
  2. Compute the integrating factor. μ(x) = e∫P(x) dx Omit the constant of integration here, we only need one particular μ.
  3. Multiply both sides by μ and recognise the left side. d/dx[μy] = μQ(x) The left side is always the derivative of the product μy. Write it that way before integrating.
  4. Integrate both sides and solve for y. μy = ∫μQ(x) dx + C   →   y = (∫μQ dx + C) / μ If an initial condition is given, substitute it now to find C.
⚠ Don't skip the constant C When you integrate both sides in Step 4, you must include +C on the right. This constant represents the entire family of solutions. An initial condition will pin it down; without one, the general solution retains C.

§ 04Real-World Applications

First-order linear ODEs govern a remarkable range of natural phenomena. Recognising these standard models lets you set up the equation before picking up a pen.

🌡
Newton's Law of Cooling
dT/dt + k(T − Tenv) = 0
Temperature of an object approaches the ambient temperature exponentially. Rewrite as dT/dt + kT = kTenv — a first-order linear ODE with P = k, Q = kTenv.
RL Electrical Circuit
L · dI/dt + RI = V(t)
Current I in a series inductor-resistor circuit. Divide by L to get standard form: dI/dt + (R/L)I = V(t)/L, with P = R/L and Q = V(t)/L.
🧪
Mixing Problems
dA/dt + (rout/V)A = rin·cin
Amount A of substance in a tank. Flow rate in minus flow rate out. The volume V may itself change with time, making P(t) = rout/V(t) non-constant.
💊
Drug Concentration
dC/dt + keC = D(t)
Concentration C of a drug in the bloodstream. ke is the elimination rate constant; D(t) is the dosing rate. Solved by the integrating factor eket.
💰
Savings with Regular Deposits
dS/dt − rS = d
Balance S growing at interest rate r with constant deposit rate d. Standard form: dS/dt + (−r)S = d. Integrating factor μ = e−rt.
🌊
Pollution Dispersal
dP/dt + k(t)P = s(t)
Pollutant concentration P with time-varying decay rate k(t) and source s(t). Only the integrating factor method handles the non-constant coefficient.

§ 05Integrating Factor Calculator

Select the form of P(x) in your equation and compute μ(x) = e^∫P dx instantly.

Find μ(x) for y′ + P(x)y = Q(x)

Integrating Factor

§ 06Worked Examples

Twelve fully solved problems: from clean constant-coefficient equations to mixing tanks and RL circuits.

Example 1 Constant P — the simplest case Pure

Solve: y′ − 2y = 4

Step 1 — Standard form
y′ + (−2)y = 4  →  P = −2,   Q = 4
Step 2 — Integrating factor
μ = e∫(−2)dx = e−2x
Step 3 — Multiply through, recognise the derivative
d/dx[e−2x y] = 4e−2x
Step 4 — Integrate both sides
e−2x y = 4 · (e−2x / −2) + C = −2e−2x + C y = −2 + Ce2x
y = Ce²ˣ − 2

Check: y′ = 2Ce²ˣ. Then y′ − 2y = 2Ce²ˣ − 2(Ce²ˣ − 2) = 4. ✓

Example 2 Constant P with initial condition IVP

Solve: y′ + 3y = 6,  y(0) = 1

P = 3, Q = 6 → μ = e³ˣ
Multiply and integrate
d/dx[e3xy] = 6e3x e3xy = 2e3x + C  →  y = 2 + Ce−3x
Apply y(0) = 1
1 = 2 + C  →  C = −1
y = 2 − e⁻³ˣ

As x → ∞, e⁻³ˣ → 0 so y → 2. The particular solution 2 is the steady state.

Example 3 P = a/x — Euler-type equation Pure

Solve: xy′ + 2y = x³  (x > 0)

Step 1 — Divide by x to get standard form
y′ + (2/x)y = x²  →  P = 2/x,   Q = x²
Step 2 — Integrating factor
μ = e∫(2/x)dx = e2ln x = x²
Step 3 — Multiply through
d/dx[x²y] = x² · x² = x⁴
Step 4 — Integrate
x²y = x⁵/5 + C  →  y = x³/5 + C/x²
y = x³/5 + C/x²
Example 4 P = a/x with IVP IVP

Solve: y′ − y/x = x,  y(1) = 3

P = −1/x → μ = e∫(−1/x)dx = e−ln x = 1/x
Multiply through by 1/x
d/dx[y/x] = x · (1/x) = 1
Integrate
y/x = x + C  →  y = x² + Cx
Apply y(1) = 3
3 = 1 + C  →  C = 2
y = x² + 2x
Example 5 P non-constant — requires careful integration Pure

Solve: y′ + 2xy = 4x

P = 2x, Q = 4x → μ = e∫2x dx = e
Multiply and write as derivative
d/dx[ey] = 4xe
Integrate right side (substitution u = x²)
ey = ∫4xedx = 2e + C
Divide by e
y = 2 + Ce−x²
y = 2 + Ce^(−x²)

As x → ±∞, Ce⁻ˣ² → 0, so every solution tends to the particular solution y = 2.

Example 6 Trigonometric Q(x) Pure

Solve: y′ + y = sin x

P = 1 → μ = eˣ
d/dx[eˣy] = eˣ sin x — integrate by parts twice
∫eˣ sin x dx = eˣ(sin x − cos x)/2 + C
Divide by eˣ
y = (sin x − cos x)/2 + Ce−x
y = (sin x − cos x)/2 + Ce⁻ˣ
Example 7 Newton's Law of Cooling Applied

A cup of coffee at 90°C is placed in a room at 20°C. The cooling constant is k = 0.05 min⁻¹. Find T(t) and the time to reach 50°C.

ODE in standard form
dT/dt + 0.05T = 0.05 × 20 = 1    [P = 0.05, Q = 1]
μ = e0.05t
d/dt[e0.05tT] = e0.05t e0.05tT = 20e0.05t + C  →  T = 20 + Ce−0.05t
Apply T(0) = 90
90 = 20 + C  →  C = 70 T(t) = 20 + 70e−0.05t
Solve T = 50
50 = 20 + 70e−0.05t  →  e−0.05t = 30/70 = 3/7 t = −ln(3/7) / 0.05 = ln(7/3) / 0.05 ≈ 16.9 min
T(t) = 20 + 70e^(−0.05t); cools to 50°C after ≈ 16.9 min
Example 8 RL Circuit — step input voltage Applied

An RL circuit has R = 4 Ω, L = 0.2 H. A constant voltage V = 12 V is switched on at t = 0 with I(0) = 0. Find I(t).

Standard form: divide by L = 0.2
dI/dt + (4/0.2)I = 12/0.2  →  dI/dt + 20I = 60
μ = e20t
d/dt[e20tI] = 60e20t e20tI = 3e20t + C  →  I = 3 + Ce−20t
Apply I(0) = 0
0 = 3 + C  →  C = −3
I(t) = 3(1 − e^(−20t)) A

I → 3 A (= V/R = 12/4) as t → ∞. The time constant τ = L/R = 0.05 s.

Example 9 Mixing problem — constant volume Applied

A 500 L tank contains pure water. Brine with concentration 0.1 kg/L flows in at 10 L/min. The well-mixed solution flows out at 10 L/min. Find the amount of salt A(t) after t minutes. When does A reach 40 kg?

Rate in − Rate out = dA/dt
dA/dt = (0.1)(10) − (A/500)(10) = 1 − A/50
Standard form
dA/dt + (1/50)A = 1    P = 1/50, Q = 1
μ = et/50
d/dt[et/50A] = et/50 A = 50 + Ce−t/50
A(0) = 0 → C = −50
A(t) = 50(1 − e−t/50)
Solve A = 40
40 = 50(1 − e−t/50)  →  e−t/50 = 0.2  →  t = 50 ln 5 ≈ 80.5 min
A(t) = 50(1 − e^(−t/50)) kg; reaches 40 kg after ≈ 80.5 min
Example 10 Mixing problem — variable volume Applied

A 200 L tank starts with 100 L of pure water. Brine at 0.5 kg/L flows in at 6 L/min; the mixture flows out at 4 L/min (so volume increases). Find A(t).

Volume at time t: V(t) = 100 + 2t
Set up ODE: rate in − rate out
dA/dt = (0.5)(6) − (A/(100+2t))(4) = 3 − 4A/(100+2t)
Standard form: P = 4/(100+2t) = 2/(50+t), Q = 3
μ = e∫2/(50+t)dt = e2 ln(50+t) = (50+t)²
Multiply through
d/dt[(50+t)²A] = 3(50+t)² (50+t)²A = (50+t)³ + C  →  A = (50+t) + C(50+t)−2
A(0) = 0 → 0 = 50 + C/2500 → C = −125000
A(t) = (50+t) − 125000(50+t)−2
A(t) = (50+t) − 125000/(50+t)²
Example 11 Savings account with continuous deposits Applied

You deposit £500/month into an account earning 6% p.a. compounded continuously. Starting with £0, find the balance S(t) after t years.

ODE (deposit rate 500 × 12 = 6000/year in continuous terms)
dS/dt = 0.06S + 6000  →  dS/dt − 0.06S = 6000
P = −0.06 → μ = e−0.06t
d/dt[e−0.06tS] = 6000e−0.06t e−0.06tS = −100000e−0.06t + C S = −100000 + Ce0.06t
S(0) = 0 → C = 100000
S(t) = 100000(e0.06t − 1)
S(t) = 100 000(e^(0.06t) − 1) £

After 10 years: S = 100000(e⁰·⁶ − 1) ≈ £82 212.

Example 12 Equation requiring an algebraic rearrangement first Pure

Solve: (1 + x²)y′ + 2xy = cos x

Divide by (1 + x²)
y′ + [2x/(1+x²)]y = cos x/(1+x²)
μ = e∫2x/(1+x²)dx = eln(1+x²) = 1 + x²
Multiply through
d/dx[(1+x²)y] = cos x
Integrate
(1+x²)y = sin x + C  →  y = (sin x + C)/(1+x²)
y = (sin x + C) / (1 + x²)

§ 07Common Mistakes

⚠ Not dividing to get standard form first If the equation is 2y′ + 6y = 10, students often write P = 6 and Q = 10. The correct first step is to divide by 2: y′ + 3y = 5, so P = 3 and Q = 5. Using the wrong P gives the wrong integrating factor and a wrong answer.
⚠ Including a constant when computing μ When you integrate P(x) to find μ, do not add a +C. Write μ = e^∫P dx and pick the simplest antiderivative. Any constant would cancel in the end, so including one just clutters the work.
⚠ Forgetting to multiply Q by μ After multiplying the left side by μ, the right side must also be multiplied by μ. The right-hand side becomes μQ(x), not just Q(x). Missing this is the single most common error.
⚠ Not writing the left side as a derivative before integrating After multiplying by μ, write d/dx[μy] = μQ explicitly before integrating. Jumping straight to the integration without recognising the product-rule structure leads to errors, especially when P(x) is complicated.
⚠ Dropping the constant of integration Every integration in Step 4 produces a +C. Omitting it gives only the particular solution, not the general solution. If no initial condition is given, C must appear in your final answer.

§ 08Practice Quiz — 10 Questions

Apply the 4-step method. Some questions ask for P(x), μ, or the final solution: read each carefully.

Score: 0 / 0
Question 1 — Standard form

Rewrite 3y′ + 9y = 12 in standard form. What is P(x)?

  1. Divide by 3: y′ + 3y = 4
  2. P(x) = 3, Q(x) = 4
Question 2 — Integrating factor

For y′ + 5y = e²ˣ, the integrating factor is μ = e^(ax). What is a?

μ = e^∫P dx. Here P = 5. ∫5 dx = 5x.
Question 3 — Recognising the derivative

After multiplying y′ + P(x)y = Q(x) by μ, the left-hand side becomes:

Question 4 — Solving for the constant

The general solution to y′ + 2y = 6 is y = 3 + Ce⁻²ˣ. If y(0) = 7, what is C?

Substitute x = 0 and y = 7 into y = 3 + Ce⁻²ˣ.
Question 5 — Integrating factor with P = 1/x

For xy′ + y = x³ (rewritten as y′ + (1/x)y = x²), what is μ(x)?

  1. P(x) = 1/x
  2. ∫(1/x)dx = ln x
  3. μ = e^(ln x) = x
Question 6 — Cooling problem

An object cools from 80°C in a 20°C room with k = 0.1 min⁻¹. The solution is T = 20 + 60e^(−0.1t). At what time (min, to 1 d.p.) does T = 40°C?

Set T = 40: 40 = 20 + 60e^(−0.1t). Solve for t using ln.
  1. 40 = 20 + 60e^(−0.1t) → 20 = 60e^(−0.1t) → e^(−0.1t) = 1/3
  2. −0.1t = ln(1/3) = −ln 3 → t = ln3/0.1 = 10 ln 3 ≈ 11.0 min
Question 7 — RL circuit

For the RL circuit ODE dI/dt + (R/L)I = V/L with I(0) = 0, what does I approach as t → ∞?

Question 8 — Mixing tank

A 100 L tank starts with pure water. Salt water (0.2 kg/L) flows in at 5 L/min; solution flows out at 5 L/min. The general solution is A(t) = 20 + Ce^(−t/20). If A(0) = 0, what is A(20) in kg, to 2 d.p.?

A(0) = 0 gives C = −20. Then A(t) = 20(1 − e^(−t/20)). Evaluate at t = 20.
  1. A(0) = 0: 0 = 20 + C → C = −20
  2. A(t) = 20(1 − e^(−t/20))
  3. A(20) = 20(1 − e⁻¹) = 20(1 − 0.3679) ≈ 12.64 kg
Question 9 — Finding the integrating factor

For y′ + (2/x)y = x³, the integrating factor is μ = x^n. What is n?

∫(2/x)dx = 2 ln x → μ = e^(2 ln x) = x².
Question 10 — Identifying the method

Which of the following ODEs is NOT first-order linear?

  1. (a) Linear: P = cos x, Q = sin x ✓
  2. (b) Linear: divide by x → y′ − (3/x)y = x³ ✓
  3. (c) Not linear: contains y², this is a Bernoulli equation ✗
  4. (d) Linear: y′ − 4y = e^(2x) ✓

§ 09What to Study Next

You can now solve any first-order linear ODE. The natural progression is to equations of higher order and more complex structure:

Cookie Settings