← SciSim / Mathematics

First-Order Ordinary Differential Equations

Slope fields, integral curves, and the three big solvable forms: separable, linear, exact.
🎓 Tier: Standard Undergraduate (Differential Equations)

📊 Section 1 — Interactive Simulation

Pick an ODE $y'=f(x,y)$. The slope field shows the direction $y$ must move at every point. Click anywhere to drop an initial condition; an integral curve traces forward and backward via RK4.

slope field
f(x₀, y₀)
y(x) at endpoint
analytic y(x)
|num − analytic|
step h
x₀, y₀
integration range
order p (empirical)

Animation

ODE Preset

Initial Condition

Integration

Display Options

Tips

• Click anywhere on the field to drop a new initial condition.
• Try Logistic: every solution converges to $y=1$ (carrying capacity).
• Halve $h$ — RK4 error drops by $16\times$ (order 4); Euler error drops by $2\times$ (order 1).

💡 Section 2 — The Idea, Step by Step

From a one-line "slope rule" to curves you can actually draw — starting with no symbols at all.

Start here — a rule for which way to step

Imagine standing on a hillside where, at every single spot, a tiny arrow tells you which way to lean for your next step. You are never handed the whole trail — only a rule for the direction to face wherever you happen to be. A first-order differential equation is exactly that kind of rule: at every point of the page it tells you how steeply your curve must rise or fall right there. Follow the arrows and a path draws itself.

Put names and a number on it

We write the rule as $y' = f(x,y)$. Here $y'$ is the steepness (the slope) of your path, and $f(x,y)$ is a recipe that hands you that slope once you say where you are, $(x,y)$. Take the simplest example, $y' = y$: "your slope always equals your height." Start at height $y=1$ when $x=0$; the rule says the slope is $1$, so you climb. Step a little to the right, $\Delta x = 0.1$, and you rise to about $y \approx 1 + 0.1\times 1 = 1.1$. Now the same rule demands a steeper slope of $1.1$. Higher means steeper means even higher — that runaway loop is exactly exponential growth, $y = e^{x}$ (true value at $x=0.1$ is $1.105\ldots$). Populations, savings, and bacteria all obey this one "rate equals amount" rule.

The precise picture (AP / intro-college)

Draw the slope $f(x,y)$ as a short segment at a whole grid of points and you get the slope field shown above. A solution, or integral curve, is any curve that stays tangent to those segments everywhere — its derivative matches the prescribed slope at every step. One rule has infinitely many solutions, a whole family; an initial condition $y(x_0)=y_0$ pins down the single curve you ride, and (when $f$ is nice) the curves never cross. When the rule is tidy you integrate by hand: separable $y'=g(x)h(y)$ splits into $\int \frac{dy}{h(y)} = \int g(x)\,dx$; linear $y'+p(x)y=q(x)$ folds up under the integrating factor $\mu=e^{\int p\,dx}$. When it isn't tidy, the simulation's RK4 marches the curve numerically, averaging four sampled slopes per step. In the panel, the preset is your choice of rule $f$, the $x_0,y_0$ sliders plant the starting point, $x_{\text{end}}$ says how far to march, and $h$ is the step length — smaller $h$, smaller error, more steps.

Try this in the sim above

• Keep $y' = y$ and drag $y_0$ up and down: every curve is just a stretched copy of $e^x$, and none of them ever touch.

• Switch to Logistic $y'=y(1-y)$ and drop initial points both above and below $1$: every curve bends toward the line $y=1$, the carrying capacity.

• On Euler vs RK4, crank the step $h$ large and watch Euler drift off the true curve while RK4 still hugs it — halving $h$ shrinks RK4's error about $16\times$ but Euler's only $2\times$.

📐 Section 3 — Three Solvable Forms & Picard's Theorem

Existence/uniqueness, then how to actually solve in three classical cases.

Picard–Lindelöf Existence & Uniqueness

Consider the IVP $y' = f(x,y)$, $y(x_0) = y_0$. If $f$ is continuous on a rectangle containing $(x_0, y_0)$ and is Lipschitz in $y$ there (i.e., $\abs{f(x, y_1) - f(x, y_2)} \le L\abs{y_1 - y_2}$), then a unique solution exists on some open interval around $x_0$.

In particular, if $f$ and $\partial f/\partial y$ are continuous, the IVP has a unique local solution. Lipschitz fails $\Rightarrow$ uniqueness can fail (e.g.\ $y' = \sqrt{y}$, $y(0)=0$ has two solutions).

Symbol Table

SymbolMeaningType
$x$ Independent variable Real, often time
$y(x)$ Unknown function — the "solution" Real-valued, differentiable
$y'$ $dy/dx$ — rate of change of $y$ Real, depends on $x$
$f(x,y)$ Right-hand side: prescribes the slope at $(x,y)$$\R^2 \to \R$
$(x_0, y_0)$ Initial condition Point in $\R^2$
$\mu(x)$ Integrating factor (linear ODE) $\mu(x) = \exp(\int p(x)\,dx)$
$F(x,y)$ Potential function (exact ODE) Level curves are solutions
$h$ Numerical step size Real, $> 0$

Three Solution Recipes

Step 1 · Separable ODEs
Form: $\dd{y}{x} = g(x)\,h(y)$. Separate variables: $\dfrac{dy}{h(y)} = g(x)\,dx$. Integrate both sides: $\int \dfrac{dy}{h(y)} = \int g(x)\,dx + C$. Solve for $y$ if possible. Caveat: dividing by $h(y)$ assumes $h(y)\neq 0$ — equilibrium solutions $h(y_*)=0$ must be checked separately.
Step 2 · Linear ODEs — derivation of integrating factor
Form: $y' + p(x)y = q(x)$. Multiply by $\mu(x)$ chosen so that $\mu(x)y' + \mu(x)p(x)y = (\mu(x) y)'$, i.e.\ $\mu' = \mu p$. This gives $\mu(x) = \exp\!\big(\int p(x)\,dx\big)$.
Step 3 · Linear ODEs — solve
With $\mu$ chosen, the equation becomes $(\mu y)' = \mu q$. Integrate: $\mu(x) y(x) = \int \mu(x) q(x)\,dx + C$. So $$y(x) = \frac{1}{\mu(x)}\!\left(\int \mu(x) q(x)\,dx + C\right).$$ Apply IC to find $C$.
Step 4 · Exact ODEs
Form: $M(x,y)\,dx + N(x,y)\,dy = 0$ (or equivalently $y' = -M/N$). It is exact iff $\partial M/\partial y = \partial N/\partial x$. In that case there exists $F(x,y)$ with $\partial F/\partial x = M$ and $\partial F/\partial y = N$. Solutions are the level curves $F(x,y) = C$.
Step 5 · Building $F$ for an exact ODE
Integrate $M$ in $x$ holding $y$ fixed: $F(x,y) = \int M\,dx + g(y)$. Differentiate in $y$ and set equal to $N$: $\partial_y\int M\,dx + g'(y) = N$. Solve for $g'(y)$, integrate to get $g$. Result: implicit solution $F(x,y) = C$.
Step 6 · Reduction to one of the above
Many ODEs reduce: homogeneous $y' = f(y/x)$ → substitute $v = y/x$, get separable in $v, x$. Bernoulli $y' + p(x)y = q(x)y^n$ → substitute $v = y^{1-n}$, get linear in $v$. Non-exact $M\,dx + N\,dy = 0$ with $M_y \neq N_x$ → find an integrating factor $\mu(x,y)$ to make it exact.
Step 7 · When no closed form exists — go numerical
Most ODEs lack closed-form solutions. Numerical integrators are essential: Euler: $y_{n+1} = y_n + h\,f(x_n, y_n)$ — order 1, error $O(h)$. RK4: weighted average of 4 slopes — order 4, error $O(h^4)$. The simulation uses RK4 by default.

Simulation ↔ Symbol Mapping

dropdown preset defines $f(x,y)$ — the right-hand side of $y' = f(x,y)$
slider x₀, y₀ initial condition $(x_0, y_0)$ — solution starts here
slider x_end upper limit of integration — final $x$ value
slider h (log) numerical step size — smaller $h$, smaller error, more steps
slider k, T_a parameters of Newton's-cooling preset
slope-field arrows at each grid point $(x, y)$, an arrow with slope $f(x,y)$ — solutions follow these tangents
readout order p empirical $p$ from $\log_2(\text{err}_h / \text{err}_{h/2})$ — RK4 should give 4, Euler 1
graph error vs h log-log error vs step size — slope is the order of the method

Worked Example — $y' + y = \sin(x),\ y(0) = 0$

Recognize: Linear, $p(x)=1$, $q(x)=\sin x$.

Integrating factor: $\mu(x) = e^{\int 1\,dx} = e^x$.

Multiply through: $(e^x y)' = e^x \sin x$.

Integrate: $\int e^x \sin x\,dx = \tfrac12 e^x(\sin x - \cos x) + C$. So $e^x y = \tfrac12 e^x(\sin x - \cos x) + C$.

Apply IC $y(0)=0$: $0 = \tfrac12(0 - 1) + C$, so $C = \tfrac12$.

Solution: $\boxed{y(x) = \tfrac12(\sin x - \cos x) + \tfrac12 e^{-x}.}$ The transient $e^{-x}/2$ dies, leaving the steady oscillation $\tfrac12(\sin x - \cos x)$.

Reference: Boyce, W. & DiPrima, R. — Elementary Differential Equations and Boundary Value Problems, 11th ed., Ch. 2 §2.1–§2.6; Strogatz, S. — Nonlinear Dynamics and Chaos, 2nd ed., Ch. 2 (1D flows); Tenenbaum & Pollard — Ordinary Differential Equations, Dover; Coddington & Levinson — Theory of Ordinary Differential Equations, Ch. 1–2 (Picard theorem).

❓ Section 4 — Frequently Asked Questions

🧮Conceptual What does "solving an ODE" actually mean?

It means finding a function $y(x)$ such that plugging $y$ and $y'$ into the equation makes it an identity for all $x$ in some interval. The equation tells you the slope at every point; the solution is a curve whose tangent at each point matches that prescribed slope. There are typically infinitely many solutions — a one-parameter family — and an initial condition $y(x_0)=y_0$ picks out one specific solution. Geometrically, the slope field shows the prescribed slopes; integral curves "thread through" the field tangentially.

Key takeaway: an ODE is a slope rule; solving = finding a curve tangent to that rule everywhere.
🔬Simulation What does the slope field show, and what does the curve do?

The slope field draws short tangent segments at a regular grid of points. At each $(x,y)$, the segment's slope is exactly $f(x,y)$ — what $y'$ must be there if a solution passes through. The integral curve is computed by RK4 starting at your chosen $(x_0, y_0)$: at each step it samples the slope at four nearby points and takes a weighted average to produce the next point. The result is a curve that's tangent to the slope field at every step — i.e., a solution of the ODE — accurate to $O(h^4)$ per step.

Key takeaway: slope field = direction recipe; integral curve = RK4 follows it tangentially.
🌍Applied Where do first-order ODEs come from?

Whenever a quantity changes at a rate that depends on its current value or on time. Population growth: $dP/dt = rP$ → exponential, then logistic when resources cap. Newton's cooling: a hot object cools at rate proportional to temperature gap with surroundings — first-order linear. Radioactive decay: $dN/dt = -\lambda N$. Drug pharmacokinetics: drug concentration in bloodstream obeys first-order elimination + dosing input. RC circuits: voltage across capacitor satisfies $RC\,V' + V = V_s(t)$ — exactly the linear ODE we solved. Compound interest with continuous deposits: linear ODE for account balance.

Key takeaway: any "rate-depends-on-amount" model is a first-order ODE — populations, temperatures, drugs, circuits, money.
💡Non-Obvious Why can two solution curves never cross?

If two solutions $y_1$ and $y_2$ crossed at a point $(x^*, y^*)$, both would satisfy $y(x^*) = y^*$ and $y'(x^*) = f(x^*, y^*)$ — same initial value, same slope. By Picard's uniqueness theorem (assuming Lipschitz $f$), there's only one solution through any point — so $y_1 = y_2$ in a neighbourhood, contradicting the assumption they were different curves. The slope field is a "non-crossing flow". When uniqueness fails (e.g., $y' = 3y^{2/3}$ at $y=0$ — not Lipschitz there), curves can branch: $y \equiv 0$ and $y = (x-c)^3$ both satisfy $y(c)=0$.

Key takeaway: Lipschitz ⇒ no crossings, by uniqueness. Non-Lipschitz ⇒ branching is possible.
📐Computational How does RK4 achieve $O(h^4)$ accuracy?

RK4 takes the step $y_{n+1} = y_n + \tfrac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4)$ where $k_1 = f(x_n, y_n)$, $k_2 = f(x_n + h/2,\ y_n + h k_1/2)$, $k_3 = f(x_n + h/2,\ y_n + h k_2/2)$, $k_4 = f(x_n + h,\ y_n + h k_3)$. The four-point Simpson-like weighted average matches the Taylor series of the true solution up to and including $h^4$ terms — the leading error is $O(h^5)$ per step, accumulating to $O(h^4)$ globally over a fixed interval. Cost per step: 4 function evaluations vs 1 for Euler. To gain a factor of 10 in accuracy: Euler needs $10\times$ more steps, RK4 needs only $10^{1/4}\approx 1.78\times$ more — RK4 wins enormously for tight tolerances.

Key takeaway: RK4 = 4-stage weighted slope average that matches Taylor through $h^4$. 4× cost, but $1/h^3$× accuracy.
🎓Deep / Advanced What's the connection between ODEs, vector fields, and dynamical systems?

An autonomous ODE $y' = f(y)$ (no $x$ dependence) defines a vector field on the line/phase space — at each $y$, a velocity vector $f(y)$. Its solution is the flow generated by integrating that field. Equilibria $f(y^*)=0$ are fixed points; their stability is determined by $f'(y^*)$: stable if $f'(y^*) < 0$, unstable if $> 0$. Generalize to $\R^n$: $\mathbf{y}' = \mathbf{F}(\mathbf{y})$ — autonomous system. Equilibria of nonlinear systems are classified by eigenvalues of the Jacobian (linearization theorem of Hartman-Grobman). This is the start of dynamical systems theory: bifurcations, attractors, chaos, structural stability — all built on the geometric view of ODEs as flows of vector fields.

Key takeaway: ODEs are vector fields; solutions are flows; equilibria + linearization launch dynamical systems theory.
🧮Conceptual What is the difference between linear, separable, and exact, and why do these special cases matter?

They're three orthogonal "structures" that allow closed-form integration. Separable: $y'$ factors as $g(x)h(y)$ — variables disentangle, two independent integrals do the job. Linear: $y$ and $y'$ appear only to the first power, no products of $y$ with itself — integrating factor turns the LHS into a perfect derivative. Exact: the ODE rewritten as $M\,dx + N\,dy = 0$ is the differential of some $F$ — the gradient/conservation viewpoint. Most random ODEs aren't any of these (e.g.\ $y' = \cos(xy)$). Recognizing the form is the first triage step before reaching for numerics. There are also tricks (substitutions: homogeneous, Bernoulli, Riccati) that convert a non-classical equation to one of these three.

Key takeaway: separable, linear, exact — three solvable forms with three different integration strategies. Try each; if none, go numerical.
Best resource: 3Blue1Brown — "Differential equations, a tourist's guide" (Differential Equations series); MIT OCW 18.03 — Differential Equations (Mattuck); Paul's Online Math Notes — Differential Equations, https://tutorial.math.lamar.edu/Classes/DE/DE.aspx; Khan Academy — Differential Equations; Strogatz lecture series, Cornell.

⚠️ Section 5 — Misconceptions & Common Errors

A · Conceptual Misconceptions
❌ Misconception: "An ODE has one solution." ✅ Correction: A first-order ODE generally has a one-parameter family of solutions — one solution for each initial condition. The general solution contains an arbitrary constant $C$; specific values of $C$ give particular solutions. Only after pinning down the IC $y(x_0)=y_0$ do you get a unique curve. Geometrically: the slope field is filled with non-crossing integral curves, one through every point.

📖 Reference: Boyce & DiPrima — Elementary Differential Equations, 11th ed., Ch. 1 (general vs particular).
❌ Misconception: "If $f(x,y)$ is continuous, the IVP $y'=f(x,y),\ y(x_0)=y_0$ has a unique solution." ✅ Correction: Continuity gives existence (Peano's theorem) but not uniqueness. Uniqueness needs $f$ to be Lipschitz in $y$ (a stronger condition), which holds e.g.\ when $\partial f/\partial y$ is continuous. Classic counterexample: $y' = 3y^{2/3}$, $y(0)=0$ — the function $f(y) = 3y^{2/3}$ is continuous but not Lipschitz at $y=0$. Solutions $y \equiv 0$ and $y = x^3$ both satisfy the IVP. 📖 Reference: Coddington & Levinson — Theory of ODEs, Ch. 1 (Picard vs Peano).
❌ Misconception: "An equation is separable if I can move all the $y$'s to one side." ✅ Correction: Separability requires the RHS to factor as $g(x)\cdot h(y)$ — a product of a function of $x$ alone and a function of $y$ alone. $y' = x + y$ has $y$ on one side ($y' - y = x$) but is not separable (it's linear instead). $y' = xy$ separates as $\frac{dy}{y} = x\,dx$. The diagnostic is whether you can write $f(x,y) = g(x)h(y)$ — sums don't factor; products do. 📖 Reference: Tenenbaum & Pollard — ODEs, §6 (separable definition).
B · Common Procedural Errors
❌ Error: "$y' + 2y = e^x$, integrating factor $\mu = e^2$." ✅ Correct: $\mu(x) = \exp(\int 2\,dx) = e^{2x}$, not $e^2$. The student forgot that the integral $\int p(x)\,dx$ where $p(x)=2$ is $2x$, not $2$. With the right $\mu$: $(e^{2x}y)' = e^{2x}\cdot e^x = e^{3x}$, so $e^{2x}y = \tfrac13 e^{3x} + C$, giving $y = \tfrac13 e^x + Ce^{-2x}$. Justifying rule: $\int p(x)\,dx$ is the antiderivative; for constant $p$, that's $px$. 🔍 Why students do this: confuse $e^{\int 2\,dx}$ with "$e$ to the 2" — drop the integration step.
❌ Error: "$\dfrac{dy}{dx} = \dfrac{x}{y} \Rightarrow y\,dy = x\,dx \Rightarrow \dfrac{y^2}{2} = \dfrac{x^2}{2}$." ✅ Correct: The integration constant! $\int y\,dy = \int x\,dx + C$, giving $\dfrac{y^2}{2} = \dfrac{x^2}{2} + C$, i.e.\ $y^2 - x^2 = 2C = K$ (rename). Solutions are hyperbolas (or asymptotes if $K=0$). Forgetting $C$ collapses the entire family to a single curve. Justifying rule: indefinite integrals always carry a constant of integration. 🔍 Why students do this: in routine $\int x\,dx$ practice the constant is often dropped; in ODE solving, $C$ is what encodes the IC.
❌ Error: "Logistic equation $y' = y(1-y)$, $y(0)=0$. Solution: separate, integrate, get $y(x) = \dfrac{1}{1+e^{-x}}$." ✅ Correct: $y(0) = 0$ is an equilibrium ($f(0)=0\cdot 1 = 0$), so the unique solution starting at $y_0=0$ is $y\equiv 0$ for all $x$. The formula $y = 1/(1 + e^{-x})$ corresponds to a different IC: $y(0) = 1/2$. The error is dividing by $y(1-y)$ when separating — that division is invalid at $y=0$ and $y=1$, which is exactly where equilibria live. Justifying rule: before separating, check whether dividing kills any equilibrium solutions; check those separately. 🔍 Why students do this: apply the separation routine mechanically without checking whether the divisor can vanish.
Education research: Rasmussen, C. — "New directions in differential equations: A framework for interpreting students' understandings and difficulties", Journal of Mathematical Behavior 20(1), 55–87 (2001); Rasmussen, C. & King, K. — "Locating starting points in differential equations: A realistic mathematics education approach", IJMEST 31(2), 161–172 (2000); Habre, S. — "Investigating students' approval of a geometrical approach to differential equations and their solutions", IJMEST 34(5), 651–662 (2003); Trigueros, M. — "Students' conceptions of solution curves and equilibrium in systems of differential equations", Proceedings of PME-NA 26 (2004); Arslan, S. — "Do students really understand what an ordinary differential equation is?", IJMEST 41(7), 873–888 (2010).