LeoMath

Introduction to differential equations

First-order equations

Separation of variables, integrating factors and the geometry of solutions.

about 7 min

Start from a problem

Problem

y′=f(t,y)y'=f(t,y) assigns a slope to every point of the plane. How do we recover the whole curve from "slopes everywhere"?

The previous section proved that a solution exists and is unique, but not how to compute it. We need methods that actually produce solutions, even if only for certain types of equation.

Observe

Choose "Logistic growth" below: y′=ry(1−yK)y'=ry\left(1-\dfrac yK\right). Vary the initial value y(0)y(0): solutions starting below climb, solutions starting above fall, all towards KK; the one starting at y(0)=0y(0)=0 stays 00 forever. No two solution curves ever cross.

Interactive experimentNumerical ODE explorer
Equation
y′=r y(1−yK)y' = r\,y\left(1-\tfrac{y}{K}\right)
Time series
Method exactEuler error at end: 1.40e-4RK4 error at end: 2.98e-7
Conjecture

A first-order equation y′=f(t,y)y'=f(t,y) prescribes a slope at every point (t,y)(t,y). Solution curves are the curves tangent to the prescribed slope everywhere. By uniqueness (see What is an ODE) exactly one solution passes through each point, so they cannot cross. And if ff factors as a function of tt times a function of yy, perhaps we can move yy and tt to opposite sides and integrate each.

Separation of variables

Proposition 2.1Separable equations

If y′=g(t)h(y)y'=g(t)h(y) with h(y)≠0h(y)\ne0, solutions satisfy ∫dyh(y)=∫g(t) dt.\int\frac{dy}{h(y)}=\int g(t)\,dt.

Proof

Let HH be an antiderivative of 1h\dfrac1h and GG one of gg. By the chain rule ddtH(y(t))=H′(y) y′=y′h(y)=g(t)=G′(t),\frac{d}{dt}H(y(t))=H'(y)\,y'=\frac{y'}{h(y)}=g(t)=G'(t), so H(y(t))=G(t)+CH(y(t))=G(t)+C.

Writing dyh(y)=g(t) dt\dfrac{dy}{h(y)}=g(t)\,dt is a mnemonic; what actually happens is the chain rule run backwards.

Example 2.1y′ = y²

∫y−2 dy=∫dt⇒−1y=t+C\int y^{-2}\,dy=\int dt\Rightarrow-\dfrac1y=t+C. From y(0)=1y(0)=1, C=−1C=-1 and y=11−ty=\dfrac1{1-t}. The solution blows up as t→1−t\to1^-: first-order solutions can reach infinity in finite time.

Example 2.2The logistic equation

∫dyy(1−y/K)=∫r dt\displaystyle\int\frac{dy}{y(1-y/K)}=\int r\,dt. Partial fractions, 1y(1−y/K)=1y+1/K1−y/K\dfrac1{y(1-y/K)}=\dfrac1y+\dfrac{1/K}{1-y/K}, give ln⁡∣y∣−ln⁡∣1−y/K∣=rt+C\ln|y|-\ln|1-y/K|=rt+C, hence y(t)=K1+(Ky0−1)e−rt.y(t)=\frac{K}{1+\left(\frac K{y_0}-1\right)e^{-rt}}. As t→∞t\to\infty, y→Ky\to K, matching the experiment. For y0=0y_0=0 separation is illegal (h(0)=0h(0)=0), but y≡0y\equiv0 is obviously a solution, an equilibrium; so is y≡Ky\equiv K.

Linear equations and integrating factors

Definition 2.1First-order linear equation

y′+p(t)y=q(t).y'+p(t)y=q(t).

Separation fails: the right side is not g(t)h(y)g(t)h(y). But the left side is "almost" the derivative of a product.

Theorem 2.2Integrating factor

Let μ(t)=e∫p(t) dt\mu(t)=e^{\int p(t)\,dt}. Then y′+py=qy'+py=q is equivalent to (μy)′=μq(\mu y)'=\mu q, so y=1μ(t)(∫μ(t)q(t) dt+C).y=\frac1{\mu(t)}\left(\int\mu(t)q(t)\,dt+C\right).

Proof

μ′=pμ\mu'=p\mu; that is the entire reason for the choice of μ\mu (see (eu)′=u′eu(e^u)'=u'e^u in The derivative). Hence (μy)′=μy′+μ′y=μy′+pμy=μ(y′+py)=μq.(\mu y)'=\mu y'+\mu'y=\mu y'+p\mu y=\mu(y'+py)=\mu q. Integrate and divide by μ\mu.

Example 2.3

y′+2y=ety'+2y=e^t: μ=e2t\mu=e^{2t}, (e2ty)′=e3t(e^{2t}y)'=e^{3t}, e2ty=13e3t+Ce^{2t}y=\tfrac13e^{3t}+C, y=13et+Ce−2ty=\tfrac13e^t+Ce^{-2t}.

Theorem 2.3Structure of solutions of a linear equation

The general solution of y′+py=qy'+py=q equals the general solution Ce−∫pCe^{-\int p} of the homogeneous equation y′+py=0y'+py=0 plus any one particular solution.

Proof

If y1,y2y_1,y_2 both solve y′+py=qy'+py=q, then (y1−y2)′+p(y1−y2)=q−q=0(y_1-y_2)'+p(y_1-y_2)=q-q=0, so y1−y2y_1-y_2 is a homogeneous solution. Conversely, homogeneous solution plus particular solution is again a solution.

This structure comes from linearity: the solution set is an affine space, a translate of the homogeneous solution space, which is a one-dimensional vector space. The same structure reappears in Second-order linear equations, where that space becomes two-dimensional.

Common mistake

Dividing by h(y)h(y) when separating variables throws away the equilibrium solutions where h(y)=0h(y)=0. For the logistic equation, y≡0y\equiv0 and y≡Ky\equiv K are lost this way and must be added back by hand. Every time you divide by an expression in yy, ask what happens when it is zero.

Application

ApplicationGeometry of solutions: the direction field

Without solving, draw at each point a short segment of slope f(t,y)f(t,y): the direction field. Solution curves are the curves that follow it. The short segments in the experiment's phase portrait are a direction field (for a two-dimensional system). Equilibria are horizontal lines where f(t,y)=0f(t,y)=0; for the logistic equation y=Ky=K attracts nearby solutions and y=0y=0 repels them.

Remark

Only a few classes of first-order equations have closed-form solutions: separable, linear, exact, and some reducible by substitution. Most cannot be solved in closed form, which does not stop us analysing them (direction fields, equilibria, stability) or solving them numerically.

Exercises

01
Solve y′=y2, y(0)=1y'=y^2,\ y(0)=1 and find y(0.5)y(0.5).
02
Which integrating factor solves y′+2y=ety'+2y=e^t?