Math Core

Lesson 7.4 · Differential Equations

Separation of variables

Slope fields show what solutions look like, but often you want an exact formula. For a large and important class of differential equations, you can get one with a single idea: move everything involving yy to one side, everything involving xx to the other, and integrate.

Separable equations

Definition

Separable differential equation

A first-order differential equation is separable if it can be written as

dydx=g(x) h(y),\frac{dy}{dx} = g(x)\,h(y),

a function of xx alone times a function of yy alone.

For example, dydx=2xy\dfrac{dy}{dx} = 2xy, dydx=xy\dfrac{dy}{dx} = \dfrac{x}{y} and dydx=ex−y=exe−y\dfrac{dy}{dx} = e^{x - y} = e^x e^{-y} are all separable. The equation dydx=x+y\dfrac{dy}{dx} = x + y is not, because a sum can't be split into a product of an xx part and a yy part.

The method

Separation of variables

To solve dydx=g(x) h(y)\dfrac{dy}{dx} = g(x)\,h(y):

  1. Separate: 1h(y) dy=g(x) dx\dfrac{1}{h(y)}\,dy = g(x)\,dx.
  2. Integrate both sides: ∫1h(y) dy=∫g(x) dx\displaystyle\int \frac{1}{h(y)}\,dy = \int g(x)\,dx, and add one constant CC.
  3. Use the initial condition to find CC (do this as soon as you can).
  4. Solve for yy, choosing signs and a domain consistent with the initial condition.

Why is this legal? If yy is a solution, then 1h(y)dydx=g(x)\dfrac{1}{h(y)}\dfrac{dy}{dx} = g(x). Integrating both sides with respect to xx, and using substitution on the left (dy=dydx dxdy = \dfrac{dy}{dx}\,dx), gives exactly the equation in step 2. Writing dydy and dxdx as if they were separate pieces is shorthand for that substitution.

You only need one constant. If you wrote C1C_1 on the left and C2C_2 on the right, you could subtract to combine them into a single constant anyway.

Worked example: A solution involving a square root

Find the particular solution of dydx=xy\dfrac{dy}{dx} = \dfrac{x}{y} with y(0)=3y(0) = 3.

Solution. Separate and integrate:

y dy=x dx⟹y22=x22+C.y\,dy = x\,dx \quad\Longrightarrow\quad \frac{y^2}{2} = \frac{x^2}{2} + C.

Use y(0)=3y(0) = 3: 92=0+C\dfrac{9}{2} = 0 + C, so C=92C = \dfrac92. Multiply by 2: y2=x2+9y^2 = x^2 + 9.

Now y=±x2+9y = \pm\sqrt{x^2 + 9}, but the initial value y(0)=3y(0) = 3 is positive, so take the positive root:

y=x2+9.y = \sqrt{x^2 + 9}.

Worked example: An exponential solution

Find the particular solution of dydx=2xy\dfrac{dy}{dx} = 2xy with y(0)=5y(0) = 5.

Solution. Separate and integrate:

1y dy=2x dx⟹ln⁡∣y∣=x2+C.\frac{1}{y}\,dy = 2x\,dx \quad\Longrightarrow\quad \ln|y| = x^2 + C.

Use y(0)=5y(0) = 5: ln⁡5=0+C\ln 5 = 0 + C, so C=ln⁡5C = \ln 5. Then

ln⁡∣y∣=x2+ln⁡5⟹∣y∣=ex2+ln⁡5=5ex2.\ln|y| = x^2 + \ln 5 \quad\Longrightarrow\quad |y| = e^{x^2 + \ln 5} = 5e^{x^2}.

Since y(0)=5>0y(0) = 5 > 0 and the solution is never 0, yy stays positive, so y=5ex2y = 5e^{x^2}.

Check: dydx=5ex2⋅2x=2x(5ex2)=2xy\dfrac{dy}{dx} = 5e^{x^2}\cdot 2x = 2x\left(5e^{x^2}\right) = 2xy. ✓

Common mistake

Add the constant when you integrate, not after you solve for yy. In the example above, a common error is to write ln⁡∣y∣=x2\ln|y| = x^2, exponentiate to get y=ex2y = e^{x^2}, and then tack on "+C+ C" to get y=ex2+Cy = e^{x^2} + C. That function is not a solution of dydx=2xy\dfrac{dy}{dx} = 2xy unless C=0C = 0. On the AP exam, a missing or misplaced constant of integration costs most of the points for the problem.

The domain of a particular solution

A particular solution is only valid on an interval that contains the initial point and on which the formula (and the differential equation) make sense. Sometimes that interval is much smaller than you'd expect.

Worked example: A solution that blows up

Find the particular solution of dydx=xy2\dfrac{dy}{dx} = xy^2 with y(0)=1y(0) = 1, and state its domain.

Solution. Separate and integrate:

y−2 dy=x dx⟹−1y=x22+C.y^{-2}\,dy = x\,dx \quad\Longrightarrow\quad -\frac{1}{y} = \frac{x^2}{2} + C.

Use y(0)=1y(0) = 1: −1=0+C-1 = 0 + C, so C=−1C = -1. Then

−1y=x22−1=x2−22⟹y=22−x2.-\frac{1}{y} = \frac{x^2}{2} - 1 = \frac{x^2 - 2}{2} \quad\Longrightarrow\quad y = \frac{2}{2 - x^2}.

This formula is undefined at x=±2x = \pm\sqrt2. The solution must be a differentiable function on an interval containing x=0x = 0, so its domain is −2<x<2-\sqrt2 < x < \sqrt2. The pieces of the graph outside that interval belong to the formula, but not to this solution.

y = 2/(2 − x²). Only the middle branch, between the dashed asymptotes, is the solution with y(0) = 1.Open in grapher →

Worked example: Solving with exponentials on both sides

Find the particular solution of dydt=et−y\dfrac{dy}{dt} = e^{t - y} with y(0)=ln⁡3y(0) = \ln 3.

Solution. Rewrite et−y=ete−ye^{t - y} = e^t e^{-y}, then separate by multiplying both sides by eye^y:

ey dy=et dt⟹ey=et+C.e^y\,dy = e^t\,dt \quad\Longrightarrow\quad e^y = e^t + C.

Use y(0)=ln⁡3y(0) = \ln 3: eln⁡3=e0+Ce^{\ln 3} = e^0 + C, so 3=1+C3 = 1 + C and C=2C = 2. Then ey=et+2e^y = e^t + 2, and taking the natural log,

y=ln⁡(et+2).y = \ln\left(e^t + 2\right).

Since et+2>0e^t + 2 > 0 for every tt, this solution is valid for all real tt.

Tip

Always check your final answer in two ways: it should satisfy the initial condition, and differentiating it should give back the original differential equation. Both checks take less than a minute.

Practice

Practice 1

Find the particular solution y=f(x)y = f(x) of dydx=3x2y\dfrac{dy}{dx} = 3x^2y with f(0)=4f(0) = 4.

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 2

Find the particular solution y=f(x)y = f(x) of dydx=xy\dfrac{dy}{dx} = \dfrac{x}{y} with f(2)=−4f(2) = -4.

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 3

Find the particular solution y=f(x)y = f(x) of dydx=ycos⁡x\dfrac{dy}{dx} = y\cos x with f(0)=2f(0) = 2.

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 4

Find the particular solution y=f(x)y = f(x) of dydx=2x(y−1)\dfrac{dy}{dx} = 2x(y - 1) with f(0)=3f(0) = 3.

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 5

Find the particular solution y=f(x)y = f(x) of dydx=x+1y2\dfrac{dy}{dx} = \dfrac{x + 1}{y^2} with f(0)=2f(0) = 2.

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 6

Find the particular solution y=f(x)y = f(x) of dydx=xe−y\dfrac{dy}{dx} = xe^{-y} with f(0)=0f(0) = 0.

Enter an expression, e.g. 3x^2 - 2x + 1

Practice 7

Let y=f(x)y = f(x) be the particular solution of dydx=2xy2\dfrac{dy}{dx} = 2xy^2 with f(0)=1f(0) = 1. What is the domain of ff?