edusolum

📖 Unit 7: Differential Equations

# Differential Equations

You already know how to find a derivative once you have a function. Differential equations flip that process around: you're handed information about how something changes — a rate — and asked to recover the function itself. A population growing in proportion to its own size, a cooling cup of coffee approaching room temperature, a rumor spreading through a school — all of these are described first by a rate, not a formula. This unit builds the tools to go from a differential equation back to the function it describes: verifying and building models, visualizing solutions with slope fields, marching forward numerically with Euler's method, and solving analytically by separating variables — culminating in the two most important growth models in calculus, exponential and logistic growth.

# Differential Equations: Definitions and Verification

# What a differential equation is

A differential equation is an equation that involves an unknown function together with one or more of its derivatives, such as $\frac{dy}{dx} = 3x + y$. The order of a differential equation is the order of the highest derivative it contains; this course focuses almost entirely on first-order differential equations, which involve only $\frac{dy}{dx}$.

A solution to a differential equation is a function $y = f(x)$ that makes the equation true when $f(x)$ and its derivatives are substituted in. Because differentiation loses constant information, solving a differential equation typically produces a whole family of functions at once:

  • a general solution includes an arbitrary constant $C$, representing every function that satisfies the equation.
  • a particular solution is one member of that family, pinned down by an initial condition — a specific point $(x_0, y_0)$ the solution must pass through.
  • a differential equation together with an initial condition is called an initial value problem (IVP).

# Verifying a solution

To verify that a given function solves a differential equation, differentiate it and substitute both the function and its derivative into the equation to confirm the two sides match.

example. Verify that $y = e^{2x}$ solves $\frac{dy}{dx} = 2y$.

$$\frac{d}{dx}\left(e^{2x}\right) = 2e^{2x}$$

Substituting $y = e^{2x}$ into the right-hand side gives $2\left(e^{2x}\right) = 2e^{2x}$. Both sides match, so $y = e^{2x}$ is a solution.

example. Verify that $y = C_1\cos x + C_2 \sin x$ solves $y'' + y = 0$.

$$y' = -C_1\sin x + C_2\cos x \qquad y'' = -C_1\cos x - C_2\sin x$$

Substituting into $y'' + y$:

$$(-C_1\cos x - C_2\sin x) + (C_1\cos x + C_2 \sin x) = 0$$

the identity $0 = 0$ holds for any $C_1, C_2$, confirming the solution.

# Translating words into a differential equation

Many AP problems begin by asking you to build the differential equation from a verbal description before solving anything.

  • "the rate of change of $y$ with respect to $x$ is proportional to $x^2$" becomes $\frac{dy}{dx} = kx^2$.
  • "the rate of change of $Q$ with respect to $t$ is inversely proportional to $Q$" becomes $\frac{dQ}{dt} = \frac{k}{Q}$.

example. State Newton's Law of Cooling as a differential equation: the rate of change of an object's temperature $T$ is proportional to the difference between $T$ and the ambient temperature $T_a$.

$$\frac{dT}{dt} = k(T - T_a)$$

# Slope Fields

# Reading the "flow" of a differential equation

When a differential equation can't be solved analytically — or before you've solved it — a slope field (direction field) lets you see its solutions visually. At every point $(x,y)$ in the plane, $\frac{dy}{dx}$ gives the slope of whatever solution curve happens to pass through that point. Plotting a short line segment with that slope at a grid of points produces a picture of how every solution curve must flow.

title: Slope field for dy/dx = x - y, with reference line y = x
xlabel: x
ylabel: y
bounds: -2, 2, -2, 2
y=x
\operatorname{polygon}((-1.15,-1),(-0.85,-1))
\operatorname{polygon}((-1.15,0.15),(-0.85,-0.15))
\operatorname{polygon}((-1.15,1.3),(-0.85,0.7))
\operatorname{polygon}((-0.15,-1.15),(0.15,-0.85))
\operatorname{polygon}((-0.15,0),(0.15,0))
\operatorname{polygon}((-0.15,1.15),(0.15,0.85))
\operatorname{polygon}((0.85,-1.3),(1.15,-0.7))
\operatorname{polygon}((0.85,-0.15),(1.15,0.15))
\operatorname{polygon}((0.85,1),(1.15,1))
  • if $\frac{dy}{dx}$ depends only on $x$, every segment in a given vertical column is parallel.
  • if $\frac{dy}{dx}$ depends only on $y$, every segment in a given horizontal row is parallel.
  • wherever $\frac{dy}{dx} = 0$, the segment is horizontal — a sign of a possible extremum for the solution curve passing through.

example. For $\frac{dy}{dx} = x - y$, where are the slopes zero?

$$x - y = 0 \implies y = x$$

slopes are zero exactly along the line $y = x$ — visible in the diagram above, where every segment sitting on that line is flat.

example. Describe the slope field of $\frac{dy}{dx} = \frac{x}{y}$.

  • slopes are $0$ along the $y$-axis ($x=0$), except at the origin, where the expression is undefined.
  • slopes are undefined along the $x$-axis ($y=0$), producing vertical segments there.
  • in Quadrant I, where $x$ and $y$ are both positive, all slopes are positive.

example. Which differential equation produces a slope field where slopes are constant along every line $y = -x + c$?

Along such a line, $x+y$ is constant, so a DE whose slope depends only on the sum $x+y$ fits — for example, $\frac{dy}{dx} = x+y$.

# Euler's Method (BC)

Euler's method is the numerical analogue of following a slope field by hand: starting at a known point, take a small step along the current tangent line, recompute the slope at the new point, and repeat.

$$x_{n+1} = x_n + h \qquad y_{n+1} = y_n + f'(x_n, y_n)\cdot h$$

Smaller step sizes $h$ generally produce more accurate approximations, though the error still accumulates step by step since each new tangent line is only exactly correct at the instant it's drawn.

flowchart TD
  A["Start at known point (x0, y0)"] --> B["Evaluate slope f(xn, yn) from the DE"]
  B --> C["Step forward: x(n+1) = xn + h"]
  C --> D["Step forward: y(n+1) = yn + f(xn, yn) times h"]
  D --> E{"Reached target x?"}
  E -->|"no"| B
  E -->|"yes"| F["Report approximation"]

example. Given $\frac{dy}{dx} = x+y$ and $y(0)=1$, approximate $y(0.2)$ using two steps of size $h=0.1$.

$n$ $x_n$ $y_n$ $dy/dx = x+y$ $\Delta y = (dy/dx),h$
0 0 1 1 0.1
1 0.1 1.1 1.2 0.12
2 0.2 1.22

so $y(0.2) \approx 1.22$.

{
  "title": "Euler's method approximation of y(x) for dy/dx = x + y, y(0) = 1",
  "data": {"values": [
    {"x": 0, "y": 1},
    {"x": 0.1, "y": 1.1},
    {"x": 0.2, "y": 1.22}
  ]},
  "mark": {"type": "line", "point": true},
  "encoding": {
    "x": {"field": "x", "type": "quantitative", "title": "x"},
    "y": {"field": "y", "type": "quantitative", "title": "Euler approximation of y"}
  }
}

example. If $\frac{d^2y}{dx^2}$ is positive throughout an interval, does Euler's method over- or underestimate the true solution there?

$y'' > 0$ means the solution curve is concave up, so its tangent lines lie below the curve everywhere except the point of tangency. Since Euler's method walks along those tangent lines, it underestimates the true solution.

example. $y(1) = 5$, $\frac{dy}{dx} = 2x$. Approximate $y(0)$ using $h = -0.5$ (stepping backward).

$$x_0=1,\ y_0=5,\ f'=2 \implies \Delta y = 2(-0.5) = -1 \implies x_1=0.5,\ y_1=4$$

$$f' = 2(0.5)=1 \implies \Delta y = 1(-0.5)=-0.5 \implies x_2=0,\ y_2=3.5$$

so $y(0) \approx 3.5$ — note that Euler's method works equally well marching backward with a negative step size.

# Separation of Variables

# The method

Separable first-order differential equations can be written as $\frac{dy}{dx} = f(x)g(y)$, letting you move every $y$ term to one side and every $x$ term to the other before integrating.

flowchart TD
  A["Write dy/dx = f(x) g(y)"] --> B["Separate: 1/g(y) dy = f(x) dx"]
  B --> C["Integrate both sides"]
  C --> D["Add + C on the x side"]
  D --> E["Solve algebraically for y"]
  E --> F["Use an initial condition to find C, if given"]

important note. you must separate the variables before integrating — integrating $\frac{dy}{dx} = x+y$ directly as $\int dy = \int (x+y),dx$ is invalid and a common source of error, since $x+y$ cannot be split into a product $f(x)g(y)$.

example. Solve $\frac{dy}{dx} = \frac{2x}{y}$.

$$y,dy = 2x,dx \implies \int y,dy = \int 2x,dx \implies \frac{y^2}{2} = x^2 + C \implies y = \pm\sqrt{2x^2+C}$$

example. Solve the initial value problem $\frac{dy}{dx} = (1+y^2)x$, $y(0) = 1$.

$$\frac{1}{1+y^2},dy = x,dx \implies \arctan(y) = \frac{x^2}{2} + C$$

Using $(0,1)$: $\arctan(1) = 0 + C \implies C = \frac{\pi}{4}$. So:

$$\arctan(y) = \frac{x^2}{2} + \frac{\pi}{4} \implies y = \tan\left(\frac{x^2}{2}+\frac{\pi}{4}\right)$$

example. Solve $\frac{dy}{dx} = \frac{y}{x}$ for $x$ positive.

$$\int \frac{1}{y},dy = \int \frac{1}{x},dx \implies \ln|y| = \ln|x| + C \implies |y| = e^C|x| \implies y = kx$$

where $k = \pm e^C$ absorbs the sign and the constant.

example. Solve $\frac{dy}{dt} = y^2 e^t$, $y(0) = 1$.

$$y^{-2},dy = e^t,dt \implies -y^{-1} = e^t + C$$

Using $y(0)=1$: $-1 = 1 + C \implies C = -2$, so $-\frac{1}{y} = e^t - 2 \implies y = \frac{1}{2-e^t}$.

example. Solve $\frac{dy}{dx} = \cos^2(y)$.

$$\sec^2(y),dy = dx \implies \tan(y) = x+C \implies y = \arctan(x+C)$$

example. Solve $\frac{dy}{dx} = e^{x-y}$.

$$\frac{dy}{dx} = \frac{e^x}{e^y} \implies e^y,dy = e^x,dx \implies e^y = e^x + C \implies y = \ln(e^x+C)$$

example. Solve $\frac{dy}{dx} = \frac{1}{x+2}$, $y(-1) = 0$.

$$y = \ln|x+2| + C \implies 0 = \ln(1) + C \implies C=0 \implies y = \ln(x+2), \quad x \text{ greater than } -2$$

example. Solve $\frac{dy}{dx} = y^2$, $y(0) = 1$, and state the domain of the particular solution.

$$\int y^{-2},dy = \int dx \implies -\frac{1}{y} = x+C$$

Using $y(0)=1$: $-1 = C$, so $-\frac{1}{y} = x - 1 \implies y = \frac{1}{1-x}$. This solution has a vertical asymptote at $x=1$; since the initial condition sits at $x=0$, the domain of the particular solution is $x$ less than $1$.

example. Solve $\frac{dy}{dx} = y\sin x$, $y(0) = e$.

$$\int \frac{1}{y},dy = \int \sin x,dx \implies \ln|y| = -\cos x + C$$

Using $y(0)=e$: $\ln(e) = -1+C \implies 1 = -1+C \implies C=2$, so $y = e^{2-\cos x}$.

example. Solve $\frac{dy}{dx} = \frac{x+1}{y}$.

$$y,dy = (x+1),dx \implies \frac{y^2}{2} = \frac{x^2}{2}+x+C \implies y = \pm\sqrt{x^2+2x+C_1}$$

example. Solve $\frac{dy}{dx} = x\sqrt{1-y^2}$.

$$\int \frac{1}{\sqrt{1-y^2}},dy = \int x,dx \implies \arcsin(y) = \frac{x^2}{2}+C \implies y = \sin\left(\frac{x^2}{2}+C\right)$$

example. Solve $\frac{dy}{dx} = \frac{1}{x}$, $y(1) = 3$.

$$y = \ln|x|+C \implies 3 = \ln(1)+C \implies C=3 \implies y=\ln|x|+3$$

# Recognizing when separation doesn't apply

Not every first-order differential equation is separable. Both $\frac{dy}{dx} = x+y$ and $\frac{dy}{dx} = x^2+y^2$ fail: neither right-hand side can be factored into a product $f(x)g(y)$, since both involve a sum of an $x$-term and a $y$-term rather than a product. Equations like these require slope fields, Euler's method, or techniques beyond this course.

# Exponential Growth and Decay

The differential equation $\frac{dy}{dt} = ky$ says the rate of change of $y$ is directly proportional to $y$ itself — the defining feature of exponential growth or decay. Separating variables:

$$\int \frac{1}{y},dy = \int k,dt \implies \ln|y| = kt+C \implies y = e^{kt+C} \implies y = Ae^{kt}$$

where $A = e^C$ turns out to be the value of $y$ at $t=0$. If $k$ is positive, $y$ grows without bound; if $k$ is negative, $y$ decays toward $0$.

title: Exponential decay, y' = -0.05y, y(0) = 100
xlabel: Time t
ylabel: y(t)
bounds: 0, 40, 0, 110
y=100e^{-0.05x}
(10, 60.65) # y(10) = 100e^-0.5

example. A substance decays according to $\frac{dy}{dt} = -0.05y$, $y(0)=100$. Find $y(10)$.

The solution is $y(t) = 100e^{-0.05t}$, so $y(10) = 100e^{-0.5} \approx 60.65$.

example. $\frac{dy}{dx} = 3y$, $y(0) = 5$. Find $y(x)$.

$$y = 5e^{3x}$$

example. If $\frac{1}{y}\frac{dy}{dt} = 0.02$, describe the growth.

Multiplying both sides by $y$ gives $\frac{dy}{dt} = 0.02y$ — exponential growth with a continuous growth rate of $2%$.

title: Newton's Law of Cooling, dT/dt = -0.1(T-20), T(0) = 80
xlabel: Time t
ylabel: Temperature T
bounds: 0, 40, 0, 90
y=20+60e^{-0.1x}
y=20

example. Solve $\frac{dT}{dt} = -0.1(T-20)$, $T(0)=80$.

$$\int \frac{1}{T-20},dT = \int -0.1,dt \implies \ln|T-20| = -0.1t+C \implies T-20 = Ae^{-0.1t}$$

Using $T(0)=80$: $60 = A$, so:

$$T(t) = 20 + 60e^{-0.1t}$$

the horizontal line $y=20$ in the graph above is the ambient temperature — the curve approaches it as $t \to \infty$ but never reaches it.

# Logistic Growth (BC)

# The model and its properties

Real populations don't grow exponentially forever — resources run out. Logistic growth models a rate that's proportional both to the current amount and to the "room" still available relative to a carrying capacity $L$:

$$\frac{dy}{dt} = ky(L-y) \qquad \text{or equivalently} \qquad \frac{dy}{dt} = ky\left(1-\frac{y}{L}\right)$$

  • if $y$ is less than $L$, then $\frac{dy}{dt}$ is positive — the population is still growing.
  • if $y$ is greater than $L$, then $\frac{dy}{dt}$ is negative — the population shrinks back down toward capacity.
  • if $y = L$, then $\frac{dy}{dt} = 0$ — growth stops entirely at capacity.
  • the maximum growth rate occurs at $y = \frac{L}{2}$, the inflection point of the logistic curve.
  • $\displaystyle\lim_{t\to\infty} y(t) = L$ regardless of the (positive) starting value.

# Solving the logistic equation

Separating variables and integrating $\displaystyle\int \frac{1}{y(L-y)},dy$ requires partial fraction decomposition. The general solution that results is:

$$y = \frac{L}{1+be^{-Lkt}}$$

where $b$ is a constant fixed by the initial condition.

title: Logistic growth curve, y = L / (1 + b e^-Lkt), with L = 1000
xlabel: Time t
ylabel: y(t)
bounds: 0, 10, 0, 1100
y=1000/(1+19e^{-2x})
y=1000
y=500

example. Solve $\frac{dy}{dt} = y(1-y)$.

$$\int \frac{1}{y(1-y)},dy = \int dt \implies \int \left(\frac1y + \frac{1}{1-y}\right)dy = t+C$$

$$\ln|y| - \ln|1-y| = t+C \implies \ln\left|\frac{y}{1-y}\right| = t+C \implies \frac{y}{1-y} = Ae^t$$

Solving for $y$:

$$y = \frac{Ae^t}{1+Ae^t} = \frac{1}{1+Ce^{-t}}$$

example. $\frac{dP}{dt} = 0.4P - 0.001P^2$. Find the carrying capacity.

Factoring: $\frac{dP}{dt} = 0.001P(400-P)$. Comparing to $kP(L-P)$ gives $L = 400$.

example. In the previous example, at what population is the growth rate maximum?

The maximum rate always occurs at $P = \frac{L}{2} = \frac{400}{2} = 200$.

example. A rumor spreads according to $\frac{dy}{dt} = 2y\left(1-\frac{y}{1000}\right)$, $y(0)=50$. Find $\displaystyle\lim_{t\to\infty}y(t)$.

This is logistic with $L=1000$; the limit as $t\to\infty$ is always the carrying capacity, so $\displaystyle\lim_{t\to\infty}y(t) = 1000$.

example. $\frac{dy}{dt} = 0.2y(10-y)$. Identify $k$ in the form $\frac{dy}{dt}=ky(L-y)$, and $r$ in the alternate form $\frac{dy}{dt}=ry\left(1-\frac{y}{L}\right)$.

Directly, $k = 0.2$. Converting: $0.2y(10-y) = 0.2(10)y\left(1-\frac{y}{10}\right) = 2y\left(1-\frac{y}{10}\right)$, so $r=2$.

example. $\frac{dP}{dt} = 3P - 0.01P^2$. Where does the point of inflection occur?

$$L = \frac{3}{0.01} = 300 \implies \text{inflection at } P = \frac{L}{2} = 150$$

example. What is $\frac{dy}{dt}$ when $y=L$ exactly?

$$\frac{dy}{dt} = k(L)(L-L) = 0$$

growth stops precisely at the carrying capacity, consistent with the horizontal asymptote seen in the logistic graph above.

# Exercises

  1. Verify that $y = 3e^{-4x}$ is a solution to $\frac{dy}{dx} = -4y$.
  2. Translate into a differential equation: "the rate of change of $P$ with respect to $t$ is proportional to the product of $P$ and $200-P$."
  3. For the differential equation $\frac{dy}{dx} = y - x$, describe where the slopes are zero and where they are positive.
  4. Given $\frac{dy}{dx} = 2x - y$ and $y(0) = 1$, use Euler's method with two steps of size $h=0.1$ to approximate $y(0.2)$.
  5. Solve $\frac{dy}{dx} = \frac{3x^2}{y}$.
  6. Solve the initial value problem $\frac{dy}{dx} = xy$, $y(0) = 4$.
  7. Explain why $\frac{dy}{dx} = x - xy$ is separable and solve it.
  8. A quantity decays exponentially with $\frac{dy}{dt} = -0.2y$ and $y(0) = 50$. Find $y(5)$.
  9. A population satisfies $\frac{dP}{dt} = 0.05P(600-P)$. Find the carrying capacity and the population at which growth is fastest.
  10. Solve $\frac{dy}{dt} = y(500-y) \cdot 0.001$ given $y(0) = 50$, expressing your answer in the form $y = \frac{L}{1+be^{-Lkt}}$.
  11. If $y''$ is negative on an interval, does Euler's method over- or underestimate the true solution there? Explain.
  12. Solve $\frac{dy}{dx} = \sec^2(x),y$.

Certificate terms & implications

Course Mastery Certificates require an active Unlimited subscription at the time of generation and 100% course completion. They recognise learning content completion only — not an accredited qualification, licence, or professional credential unless explicitly stated. edusolum may modify eligibility, design, and issuance requirements per its Terms of Service.