Skip to content
Educora
University35 min75 / 82

Differential equations

Ordinary differential equations and their order, separable equations, first-order linear equations and the integrating factor, exponential growth, decay and cooling, second-order equations with constant coefficients and the harmonic oscillator.

Check yourself
In this lesson you will learn
  • Determine the order of a differential equation and check a solution by substitution
  • Solve separable and first-order linear equations
  • Model growth, radioactive decay and cooling
  • Solve second-order equations with constant coefficients via the characteristic equation

Tea cools, a colony of bacteria grows, radioactive atoms decay, a weight on a spring oscillates. The laws behind these processes do not give the quantity itself but how fast it changes: “the rate of cooling is proportional to the temperature difference”, “the force pulls back in proportion to the displacement”. An equation that contains an unknown function together with its derivatives is a differential equation, and solving it means predicting the future from the law of change.

What is a differential equation?

Definition
Ordinary differential equation (ODE)

An equation that links an unknown function y(x) with its derivatives: F(x, y, y′, …, y⁽ⁿ⁾) = 0. The order is the order of the highest derivative that appears. A solution is a function that turns the equation into an identity. The general solution of an n-th order equation contains n arbitrary constants; initial conditions (an initial value problem) select one particular solution.

y′ = 2x is a first-order equation; integrating gives y = x² + C, a whole family of parabolas. The condition y(0) = 1 picks one parabola from the family: y = x² + 1. y″ + y = 0 is of second order; its general solution y = C₁ cos x + C₂ sin x depends on two constants.

Separable equations

dy/dx = f(x) · g(y) ⇒ ∫ dy / g(y) = ∫ f(x) dxdy/dx = f(x) · g(y) ⇒ ∫ dy / g(y) = ∫ f(x) dx
where:
  • f(x)a factor that depends only on x
  • g(y)a factor that depends only on y, g(y) ≠ 0

Move everything with y to the left and everything with x to the right, then integrate both sides.

Separating the variables

a) Solve dy/dx = x · y with y(0) = 2.
b) Find the general solution of dy/dx = −x/y.

Show solution
a) dy/y = x dx ⇒ ln|y| = x²/2 + C₀ ⇒ y = C · e^(x²/2).
y(0) = C = 2 ⇒ y = 2e^(x²/2).
Check: y′ = 2e^(x²/2) · x = x · y ✓.
b) y dy = −x dx ⇒ y²/2 = −x²/2 + C₀ ⇒ x² + y² = C: the solutions are circles centred at the origin (compare with y′ = −x/y in the lesson on derivatives).

Exponential growth, decay and cooling

dN/dt = k · N ⇒ N(t) = N₀ · eᵏᵗdN/dt = k · N ⇒ N(t) = N₀ · eᵏᵗ
where:
  • N₀the initial amount (at t = 0)
  • kthe rate constant, 1/time: k > 0 growth, k < 0 decay
  • ttime

The rate of change is proportional to the amount itself. Half-life (k < 0): T = ln 2 / |k|; doubling time (k > 0): T = ln 2 / k.

Radiocarbon

Carbon-14 has a half-life of about 5730 years. What fraction remains after 11,460 years? And after 1000 years?

Show solution
Since k = −ln 2 / T, eᵏᵗ = 2^(−t/T), so N(t) = N₀ · (1/2)^(t/T).
11,460 = 2 · 5730 years: two half-lives, so 1/4 remains.
1000 years: (1/2)^(1000/5730) = 2^(−0.1745) ≈ 0.886, about 88.6%.
Radiocarbon dating runs this calculation backwards: from the measured fraction it finds t.
dT/dt = −k (T − Tₘ) ⇒ T(t) = Tₘ + (T₀ − Tₘ) · e⁻ᵏᵗdT/dt = −k (T − Tₘ) ⇒ T(t) = Tₘ + (T₀ − Tₘ) · e⁻ᵏᵗ
where:
  • Tₘthe temperature of the surroundings (the room)
  • T₀the initial temperature
  • kthe cooling constant, k > 0

Newton's law of cooling: the temperature difference decays exponentially.

A cup of tea

Tea at 90 °C is left in a room at 20 °C. After 5 minutes it is at 60 °C. When will it reach 40 °C?

Show solution
T(t) = 20 + 70e⁻ᵏᵗ.
60 = 20 + 70e⁻⁵ᵏ ⇒ e⁻⁵ᵏ = 4/7 ⇒ k = ln(7/4)/5 ≈ 0.112 per minute.
40 = 20 + 70e⁻ᵏᵗ ⇒ e⁻ᵏᵗ = 2/7 ⇒ t = ln 3.5 / k = 5 · ln 3.5 / ln 1.75 ≈ 11.2 min.
Sanity check: the first 30 degrees took 5 minutes, the next 20 degrees take about 6 more: cooling slows down as the difference shrinks.
Interactive
Loading simulation…
N(t) = C · eᵏᵗ (the horizontal axis is the time t). k > 0: growth, the curve gets steeper and steeper; k < 0: decay towards 0; k = 0: nothing changes. C is the value at t = 0.

First-order linear equations

y′ + p(x) · y = q(x), μ(x) = e^(∫ p(x) dx), y = (1/μ) · (∫ μ · q dx + C)y′ + p(x) · y = q(x), μ(x) = e^(∫ p(x) dx), y = (1/μ) · (∫ μ · q dx + C)
where:
  • p(x), q(x)given functions
  • μ(x)the integrating factor

Multiplying by μ turns the left side into the derivative of a product: (μ · y)′ = μ · q.

Why does it work? With μ = e^(∫ p dx) we have μ′ = p · μ. After multiplying the equation by μ, the left side becomes μy′ + μ′y, which by the product rule is exactly (μ · y)′. So a single integration solves the equation.

The integrating factor at work

Solve y′ + y = x with y(0) = 1.

Show solution
p(x) = 1, so μ = eˣ.
(eˣ · y)′ = x eˣ ⇒ eˣ · y = ∫ x eˣ dx = x eˣ − eˣ + C (integration by parts).
y = x − 1 + C e⁻ˣ.
y(0) = −1 + C = 1 ⇒ C = 2: y = x − 1 + 2e⁻ˣ.
Check: y′ = 1 − 2e⁻ˣ, y′ + y = 1 − 2e⁻ˣ + x − 1 + 2e⁻ˣ = x ✓. For large x the term 2e⁻ˣ dies out and y ≈ x − 1.

Second-order linear equations with constant coefficients

a · y″ + b · y′ + c · y = 0, y = eʳˣ ⇒ a · r² + b · r + c = 0
where:
  • a, b, cconstant coefficients, a ≠ 0
  • ra root of the characteristic equation

Substituting y = eʳˣ turns the differential equation into a quadratic equation, the characteristic equation.

D = b² − 4acRootsGeneral solution
D > 0real r₁ ≠ r₂y = C₁e^(r₁x) + C₂e^(r₂x)
D = 0a repeated root r₁ = r₂ = ry = (C₁ + C₂x) eʳˣ
D < 0complex r = α ± βiy = eᵅˣ (C₁ cos βx + C₂ sin βx)
Three cases, according to the discriminant of the characteristic equation.
Three cases, three examples

a) y″ − 5y′ + 6y = 0
b) y″ + 4y′ + 4y = 0
c) y″ + 2y′ + 5y = 0, y(0) = 1, y′(0) = 0

Show solution
a) r² − 5r + 6 = 0 ⇒ r = 2, r = 3: y = C₁e²ˣ + C₂e³ˣ.
b) r² + 4r + 4 = (r + 2)² = 0 ⇒ r = −2 (a double root): y = (C₁ + C₂x)e⁻²ˣ.
c) r² + 2r + 5 = 0, D = 4 − 20 = −16 ⇒ r = −1 ± 2i: y = e⁻ˣ(C₁ cos 2x + C₂ sin 2x).
y(0) = C₁ = 1; y′(0) = −C₁ + 2C₂ = 0 ⇒ C₂ = 1/2.
y = e⁻ˣ(cos 2x + (1/2) sin 2x), a damped oscillation.

The harmonic oscillator. For a mass m on a spring of stiffness k, Newton's second law gives m · x″ = −k · x, i.e. x″ + ω²x = 0 with ω = √(k/m). The characteristic roots are r = ±iω (the case D < 0 with α = 0), so x(t) = A cos(ωt + φ): a harmonic oscillation. A pendulum at small angles obeys the same equation θ″ + (g/L)θ = 0, because sin θ ≈ θ (remember the lesson on series!).

x″ + ω² x = 0 ⇒ x(t) = A cos(ωt + φ), ω = √(k/m), T = 2π/ω = 2π √(m/k)x″ + ω² x = 0 ⇒ x(t) = A cos(ωt + φ), ω = √(k/m), T = 2π/ω = 2π √(m/k)
where:
  • Athe amplitude, m
  • φthe initial phase, rad
  • ωthe angular frequency, rad/s
  • Tthe period, s
  • m, kthe mass (kg) and the spring stiffness (N/m)

Harmonic oscillations: the period does not depend on the amplitude.

A mass on a spring

A mass m = 0.5 kg hangs on a spring with k = 50 N/m. It is pulled down 5 cm and released from rest. Find ω, T and x(t).

Show solution
ω = √(50/0.5) = √100 = 10 rad/s.
T = 2π/10 ≈ 0.63 s.
Initial conditions x(0) = 0.05 m, x′(0) = 0 ⇒ A = 0.05 m, φ = 0: x(t) = 0.05 cos 10t (m).
Check: x″ = −5 cos 10t = −100 · x ✓.
Interactive
Loading simulation…
A damped oscillation x(t) = A e^(−bt) cos ωt (the solution of m · x″ + c · x′ + k · x = 0 when the damping is small) and its envelope A e^(−bt). b = 0 gives an undamped harmonic oscillation; increase b and the swings die out faster.

Key points

  • A differential equation links a function with its derivatives; the order is the highest derivative, and the general solution has as many constants as the order.
  • Separable: dy/dx = f(x)g(y) ⇒ ∫ dy/g(y) = ∫ f(x) dx.
  • N′ = kN ⇒ N = N₀eᵏᵗ; half-life T = ln 2/|k|; cooling: T(t) = Tₘ + (T₀ − Tₘ)e⁻ᵏᵗ.
  • y′ + p y = q: multiply by μ = e^(∫ p dx), then (μy)′ = μq.
  • ay″ + by′ + cy = 0: solve ar² + br + c = 0; the cases D > 0, D = 0, D < 0 give exponentials, (C₁ + C₂x)eʳˣ, or oscillations.

Check yourself

10 questions. Every correct answer earns XP.

1 / 10
What is the integrating factor for y′ + (2/x) · y = 1 (x > 0)?