← Back to modules

Differential Equations

Solve basic differential equations and interpret models.

A differential equation (DE) is any equation that involves a function and its derivatives. Solving a DE means finding the function itself. This is the reverse of what you've been doing: instead of 'given ff, find ff'', now it's 'given a relationship involving ff' (and maybe ff''), find ff'.

Differential equations model nearly everything that changes: population growth, radioactive decay, temperature cooling, spring motion, electrical circuits, and fluid flow. If something evolves over time, there's a DE behind it.

We'll start with the simplest types (separable, linear first-order) and build up to second-order equations. The key is recognizing which type you're dealing with, then applying the appropriate solution technique.

What is a differential equation?

A DE relates a function y(x)y(x) to its derivatives. The order of a DE is the highest derivative that appears.

First-order: involves yy' (but not yy''). Example: y=2xyy' = 2xy.

Second-order: involves yy''. Example: y+4y=0y'' + 4y = 0 (simple harmonic motion).

A solution is a function y(x)y(x) that satisfies the equation for all xx in some interval.

The general solution contains arbitrary constants (one constant for first-order, two for second-order). An initial value problem (IVP) provides conditions to determine these constants.


Direction fields (slope fields)

A direction field visualizes a first-order DE y=f(x,y)y' = f(x,y) by drawing short line segments with slope f(x,y)f(x,y) at many points (x,y)(x,y).

The solution curves must be tangent to these segments at every point. So by drawing segments, you can see the shape of solutions without solving the equation.

Direction fields build intuition: you can spot equilibrium solutions (horizontal segments), identify whether solutions grow or decay, and see the qualitative behavior before doing any algebra.

Example: for y=yy' = -y, the slopes are negative when y>0y > 0 and positive when y<0y < 0. Solutions decay toward y=0y = 0, which matches y=Cexy = Ce^{-x}.

💡Explain it simply

Imagine a field of grass with wind blowing in different directions at different spots. At each point, you draw a tiny arrow showing which way the wind blows there.

A direction field is exactly that for a differential equation. At every point (x,y)(x,y), the equation tells you the slope (direction) a solution would travel through that point. Draw that slope as a tiny line segment.

Now if you drop a leaf (a solution) anywhere in the field, it will follow the arrows. The path it traces is the solution curve. You can see the overall behavior — where things flow, where they settle — without ever solving the equation algebraically.


Separable equations

A first-order DE is separable if it can be written as dydx=g(x)h(y)\frac{dy}{dx} = g(x) \cdot h(y), where one factor depends only on xx and the other only on yy.

To solve: separate the variables: 1h(y)dy=g(x)dx\frac{1}{h(y)}\,dy = g(x)\,dx. Then integrate both sides.

Don't forget the constant of integration! Usually written as +C+C on one side.

Example: dydx=xy\frac{dy}{dx} = xy. Separate: 1ydy=xdx\frac{1}{y}\,dy = x\,dx. Integrate: lny=x22+C\ln|y| = \frac{x^2}{2} + C. Solve: y=Aex2/2y = Ae^{x^2/2} where A=±eCA = \pm e^C.

Watch for lost solutions: when dividing by h(y)h(y), any value where h(y)=0h(y) = 0 might be a constant solution (equilibrium) that you lose in the algebra.

1

Solving a separable equation with an IVP

  1. Solve dydx=xy\frac{dy}{dx} = \frac{x}{y} with y(0)=2y(0) = 2.
  2. Step 1 — separate: move all yy terms to the left, xx terms to the right. Multiply both sides by yy: ydy=xdxy\,dy = x\,dx.
  3. Step 2 — integrate both sides: ydy=xdx\int y\,dy = \int x\,dx, giving y22=x22+C\frac{y^2}{2} = \frac{x^2}{2} + C.
  4. Step 3 — apply the initial condition y(0)=2y(0) = 2: 42=0+C\frac{4}{2} = 0 + C, so C=2C = 2.
  5. Step 4 — solve for yy: y2=x2+4y^2 = x^2 + 4, so y=x2+4y = \sqrt{x^2 + 4} (positive root since y(0)=2>0y(0) = 2 > 0).
  6. This is a family of hyperbolas. The initial condition picked out the specific upper branch passing through (0,2)(0, 2).

Exponential growth and decay

The DE dydt=ky\frac{dy}{dt} = ky is separable with solution y(t)=y0ekty(t) = y_0 e^{kt} where y0=y(0)y_0 = y(0).

If k>0k > 0: exponential growth (populations, compound interest, viral spread).

If k<0k < 0: exponential decay (radioactive decay, cooling, drug elimination).

Half-life: the time for the quantity to halve. If y=y0ekty = y_0 e^{kt}, the half-life is t1/2=ln2kt_{1/2} = \frac{\ln 2}{|k|}.

Doubling time: the time for the quantity to double. Doubling time =ln2k= \frac{\ln 2}{k} for k>0k > 0.


Newton's Law of Cooling

The temperature of an object changes at a rate proportional to the difference between its temperature and the ambient temperature: dTdt=k(TTenv)\frac{dT}{dt} = -k(T - T_{\text{env}}).

This is separable. Solution: T(t)=Tenv+(T0Tenv)ektT(t) = T_{\text{env}} + (T_0 - T_{\text{env}})e^{-kt} where T0T_0 is the initial temperature.

As tt \to \infty, T(t)TenvT(t) \to T_{\text{env}}. The object approaches room temperature exponentially.


Linear first-order equations

Standard form: dydx+P(x)y=Q(x)\frac{dy}{dx} + P(x)y = Q(x). The key: this is always solvable using an integrating factor.

Integrating factor: μ(x)=eP(x)dx\mu(x) = e^{\int P(x)\,dx}.

Multiply the entire equation by μ\mu: the left side becomes ddx[μ(x)y]\frac{d}{dx}[\mu(x) \cdot y].

Integrate both sides: μ(x)y=μ(x)Q(x)dx+C\mu(x) \cdot y = \int \mu(x) Q(x)\,dx + C.

Solve for yy: y=1μ(x)[μ(x)Q(x)dx+C]y = \frac{1}{\mu(x)}\left[\int \mu(x) Q(x)\,dx + C\right].

Why it works: multiplying by μ\mu turns the left side into a perfect derivative, which can be integrated directly.

1

Solving with an integrating factor

  1. Solve dydx+2y=4ex\frac{dy}{dx} + 2y = 4e^{-x}.
  2. Step 1 — identify: P(x)=2P(x) = 2 and Q(x)=4exQ(x) = 4e^{-x}. Already in standard form.
  3. Step 2 — compute the integrating factor: μ(x)=e2dx=e2x\mu(x) = e^{\int 2\,dx} = e^{2x}.
  4. Step 3 — multiply the entire equation by μ\mu: e2xdydx+2e2xy=4exe2xe^{2x}\frac{dy}{dx} + 2e^{2x}y = 4e^{-x} \cdot e^{2x}.
  5. The left side is now ddx[e2xy]\frac{d}{dx}[e^{2x} y] (that's the whole point of the integrating factor). The right side simplifies to 4ex4e^{x}.
  6. Step 4 — integrate both sides: e2xy=4exdx=4ex+Ce^{2x} y = \int 4e^{x}\,dx = 4e^{x} + C.
  7. Step 5 — solve for yy: y=4ex+Ce2x=4ex+Ce2xy = \frac{4e^{x} + C}{e^{2x}} = 4e^{-x} + Ce^{-2x}.
  8. The term Ce2xCe^{-2x} is the transient part (dies off), while 4ex4e^{-x} is the 'steady-state' particular solution.

Logistic growth

The logistic equation models growth with a carrying capacity KK: dPdt=rP(1PK)\frac{dP}{dt} = rP\left(1 - \frac{P}{K}\right).

When PP is small compared to KK, growth is approximately exponential (rP\approx rP). As PP approaches KK, growth slows and stops.

Solution: P(t)=K1+AertP(t) = \frac{K}{1 + Ae^{-rt}} where A=KP0P0A = \frac{K - P_0}{P_0}.

The graph is an S-shaped (sigmoidal) curve. The population grows fastest at P=K/2P = K/2 (the inflection point).

Applications: population biology, spread of diseases, adoption of technology, logistic regression in machine learning.

💡Explain it simply

Imagine rabbits on an island. At first there are few rabbits and lots of food, so the population explodes (exponential growth). But as the island fills up, food gets scarce, rabbits compete, and growth slows down. Eventually, the population levels off at the maximum the island can support (the carrying capacity).

The logistic equation captures this perfectly. The (1P/K)(1 - P/K) part acts like a brake. When PP is tiny, the brake is barely on and growth is fast. When PP is close to KK, the brake is almost fully on and growth nearly stops.

This S-shaped curve shows up everywhere: the spread of a new app, a virus through a population, a rumor through a school. Fast start, rapid middle, gradual leveling off.


Bernoulli equations

A Bernoulli equation has the form dydx+P(x)y=Q(x)yn\frac{dy}{dx} + P(x)y = Q(x)y^n where n0,1n \neq 0, 1.

Trick: substitute v=y1nv = y^{1-n}, then dvdx=(1n)yndydx\frac{dv}{dx} = (1-n)y^{-n}\frac{dy}{dx}.

After substitution, the equation becomes linear in vv: dvdx+(1n)P(x)v=(1n)Q(x)\frac{dv}{dx} + (1-n)P(x)v = (1-n)Q(x).

Solve the linear equation for vv, then convert back to yy.


Second-order linear homogeneous equations

Standard form: ay+by+cy=0ay'' + by' + cy = 0 with constant coefficients.

Guess y=erxy = e^{rx}, substitute, and get the characteristic equation: ar2+br+c=0ar^2 + br + c = 0.

Case 1 - Two distinct real roots r1,r2r_1, r_2: general solution is y=C1er1x+C2er2xy = C_1 e^{r_1 x} + C_2 e^{r_2 x}.

Case 2 - Repeated root rr: general solution is y=(C1+C2x)erxy = (C_1 + C_2 x)e^{rx}. The extra xx factor accounts for the repeated root.

Case 3 - Complex roots r=α±βir = \alpha \pm \beta i: general solution is y=eαx(C1cos(βx)+C2sin(βx))y = e^{\alpha x}(C_1 \cos(\beta x) + C_2 \sin(\beta x)). This produces oscillatory behavior (springs, circuits).

1

Complex roots: oscillation

  1. Solve y+4y=0y'' + 4y = 0.
  2. Guess y=erxy = e^{rx} and substitute: r2erx+4erx=0r^2 e^{rx} + 4e^{rx} = 0, so r2+4=0r^2 + 4 = 0.
  3. Solve: r2=4r^2 = -4, giving r=±2ir = \pm 2i. These are complex roots with α=0\alpha = 0 and β=2\beta = 2.
  4. Apply the complex root formula: y=e0x(C1cos(2x)+C2sin(2x))y = e^{0 \cdot x}(C_1 \cos(2x) + C_2 \sin(2x)).
  5. Simplify: y=C1cos(2x)+C2sin(2x)y = C_1 \cos(2x) + C_2 \sin(2x).
  6. This is pure oscillation with no decay (because α=0\alpha = 0). The angular frequency is ω=2\omega = 2, giving a period of T=2π2=πT = \frac{2\pi}{2} = \pi.
  7. Physical meaning: this models an ideal spring with no friction — it bounces forever.
2

Distinct real roots with initial conditions

  1. Solve y5y+6y=0y'' - 5y' + 6y = 0 with y(0)=1y(0) = 1 and y(0)=0y'(0) = 0.
  2. Characteristic equation: r25r+6=(r2)(r3)=0r^2 - 5r + 6 = (r-2)(r-3) = 0. Roots: r=2r = 2 and r=3r = 3.
  3. General solution: y=C1e2x+C2e3xy = C_1 e^{2x} + C_2 e^{3x}.
  4. Apply y(0)=1y(0) = 1: C1+C2=1C_1 + C_2 = 1.
  5. For y(0)=0y'(0) = 0: first find y=2C1e2x+3C2e3xy' = 2C_1 e^{2x} + 3C_2 e^{3x}, then y(0)=2C1+3C2=0y'(0) = 2C_1 + 3C_2 = 0.
  6. Solve the system: from 2C1+3C2=02C_1 + 3C_2 = 0 we get C1=32C2C_1 = -\frac{3}{2}C_2. Substituting into C1+C2=1C_1 + C_2 = 1: 32C2+C2=1-\frac{3}{2}C_2 + C_2 = 1, so C2=2C_2 = -2 and C1=3C_1 = 3.
  7. Final answer: y=3e2x2e3xy = 3e^{2x} - 2e^{3x}.

Non-homogeneous equations and particular solutions

Form: ay+by+cy=g(x)ay'' + by' + cy = g(x) where g(x)0g(x) \neq 0.

The general solution is y=yh+ypy = y_h + y_p where yhy_h is the homogeneous solution (solve with g=0g=0) and ypy_p is any particular solution.

Method of undetermined coefficients: guess the form of ypy_p based on g(x)g(x).

If g(x)=ekxg(x) = e^{kx}, try yp=Aekxy_p = Ae^{kx}. If g(x)=sin(kx)g(x) = \sin(kx) or cos(kx)\cos(kx), try yp=Acos(kx)+Bsin(kx)y_p = A\cos(kx) + B\sin(kx). If g(x)g(x) is a polynomial of degree nn, try a polynomial of degree nn.

If your guess duplicates a term in yhy_h, multiply by xx (or x2x^2 if needed).

Variation of parameters is a more general method that works for any g(x)g(x) but involves more computation.


Applications: springs and oscillations

A mass-spring system obeys my+cy+ky=F(t)my'' + cy' + ky = F(t) where mm is mass, cc is damping, kk is spring constant, and F(t)F(t) is external force.

Undamped free oscillation (c=0c=0, F=0F=0): y+ω2y=0y'' + \omega^2 y = 0 with ω=k/m\omega = \sqrt{k/m}. Solution: y=Acos(ωt)+Bsin(ωt)y = A\cos(\omega t) + B\sin(\omega t). Pure sinusoidal motion.

Damped oscillation (c>0c > 0, F=0F=0): the solution includes eαte^{\alpha t} with α<0\alpha < 0, causing the amplitude to decay over time.

Overdamped (c2>4mkc^2 > 4mk): no oscillation, just slow return to equilibrium.

Critically damped (c2=4mkc^2 = 4mk): fastest return to equilibrium without oscillating.

Underdamped (c2<4mkc^2 < 4mk): oscillation with decaying amplitude.

💡Explain it simply

Think of a kid on a swing. If nobody pushes and there's no friction, the swing goes back and forth forever at the same height — that's undamped oscillation.

Now add friction (air resistance, rusty chains). The swing still goes back and forth, but each swing is a little smaller until it stops — that's underdamped (oscillation with decay).

If you put the swing in thick honey, it wouldn't even swing — it would just slowly drift back to the bottom. That's overdamped. Critically damped is the sweet spot: the fastest return to rest without any overshooting. Engineers design car suspensions and door closers to be critically damped.


Initial value problems (IVPs)

An IVP provides the DE plus enough initial conditions to determine all constants.

First-order: one condition, typically y(x0)=y0y(x_0) = y_0.

Second-order: two conditions, typically y(x0)=y0y(x_0) = y_0 and y(x0)=v0y'(x_0) = v_0.

Procedure: solve the general solution first, then plug in the initial conditions and solve for the constants.

The Existence and Uniqueness Theorem: under mild conditions, a first-order IVP has exactly one solution through any given point.


⚠️

Common Mistakes to Avoid

  • Forgetting the constant of integration after separating and integrating. Every integration step produces a +C+C.
  • Not separating variables completely before integrating. All yy-terms must be on one side, all xx-terms on the other.
  • Plugging in initial conditions before finding the general solution. Get the general solution with constants first, then determine the constants.
  • Forgetting to multiply the entire equation (both sides) by the integrating factor in linear first-order DEs.
  • For second-order equations, forgetting the repeated root case. If the characteristic equation has a double root rr, the second solution is xerxxe^{rx}, not just erxe^{rx}.
  • In undetermined coefficients, using a guess that duplicates a homogeneous solution. You must multiply by xx to fix this.
  • Confusing the general solution with a particular solution. The general solution always contains arbitrary constants; a particular solution has specific values determined by initial conditions.
  • Dividing by yy in a separable equation and losing the equilibrium solution y=0y = 0.

Worked Practice Problems (5 examples)

Study these solved examples to understand the techniques. Then head to Practice to try problems on your own.

Practice on your own →
1

Problem 1

Solve dydx=3\frac{dy}{dx} = 3

Step-by-Step Solution

1

Integrate both sides: y=3dx=3x+Cy = \int 3\,dx = 3x + C.

Final Answer: y=3x+Cy = 3x + C

2

Problem 2

Solve dydx=2x\frac{dy}{dx} = 2x

Step-by-Step Solution

1

y=2xdx=x2+Cy = \int 2x\,dx = x^2 + C.

Final Answer: y=x2+Cy = x^2 + C

3

Problem 3

Solve dydx=ex\frac{dy}{dx} = e^x

Step-by-Step Solution

1

y=exdx=ex+Cy = \int e^x\,dx = e^x + C.

Final Answer: y=ex+Cy = e^x + C

4

Problem 4

Solve dydx=2y\frac{dy}{dx} = 2y (general solution)

Step-by-Step Solution

1

Separate: dyy=2dx\frac{dy}{y} = 2\,dx.

2

lny=2x+C1\ln|y| = 2x + C_1.

3

y=Ce2xy = Ce^{2x}.

Final Answer: y=Ce2xy = Ce^{2x}

5

Problem 5

Solve dydx=y\frac{dy}{dx} = -y (general solution)

Step-by-Step Solution

1

Separate: dyy=dx\frac{dy}{y} = -dx.

2

lny=x+C1\ln|y| = -x + C_1.

3

y=Cexy = Ce^{-x}.

Final Answer: y=Cexy = Ce^{-x}

Ready to practice?

Test your understanding with 40 problems on differential equations.