← SciSim / Mathematics

First-Order ODEs

Separable, linear, logistic -- direction fields, Euler method, exact solutions animated.
🎓 Tier: Standard Undergraduate -- Differential Equations

📊 Section 1 -- Interactive Simulation

y(t) Euler
--
y exact
--
|Error|
--
Step h
--
n steps
--
f(t,y)
--

Controls

ODE y = f(t,y)

Display

💡 Section 2 -- The Idea, Step by Step

Imagine someone hands you a single rule: "Tell me where you are right now, and I'll tell you how fast you're changing." That rule is a first-order differential equation. It never gives your position directly -- only your speed at this very instant. Your job is to start somewhere and let the rule carry you forward, moment by moment, like driving a car where the speedometer reading depends on where you happen to be.

Here the changing thing is $y$, time is $t$, and the rate of change is $y'=dy/dt$. The rule is written $y'=f(t,y)$. Think of a hot cup of coffee: the further its temperature sits above the room, the faster it cools, so $y'=-y$. Start at $y_0=1$ and take one small step of size $h=0.1$. The new value is roughly the old value plus (step)(rate): $y_0+h\cdot(-y_0)=1-0.1=0.9$. Keep stepping and you trace the whole cooling curve without ever needing a tidy formula.

The precise statement pairs the rule with a starting point: $y'=f(t,y)$ with $y(t_0)=y_0$ -- an initial-value problem. The direction field draws a tiny segment of slope $f(t,y)$ at every point of the plane, and any solution is simply a curve that stays tangent to those segments everywhere it goes. When the rule factors as $y'=g(t)h(y)$ you can separate and integrate each side on its own; when it is linear, $y'+p(t)y=q(t)$, multiplying by the integrating factor $e^{\int p\,dt}$ collapses the left side into the single derivative $(\mu y)'$. The Euler method turns the coffee-cup trick into a recipe, $y_{n+1}=y_n+h\,f(t_n,y_n)$, whose error shrinks in direct proportion to the step $h$. In the panel, the Initial y0 slider chooses where your curve starts and the Step h slider sets how big each Euler step is.

Try this in the sim above

1) Choose y'=y(1-y) (logistic) and slide $y_0$ both above and below 1 -- every curve bends toward the stable line $y=1$. 2) Choose y'=-y and push $h$ up to 0.5: the Euler staircase visibly peels away from the gold exact curve, then tightens back onto it as you shrink $h$. 3) Switch the lower graph to Error vs h and watch the error fall along a straight log-log line of slope $\approx 1$ -- the fingerprint of a first-order method.

📐 Section 3 -- First-Order ODEs

Picard-Lindelof Existence & Uniqueness

If $f(t,y)$ is continuous and Lipschitz in $y$ near $(t_0,y_0)$, then $y'=f(t,y)$, $y(t_0)=y_0$ has a unique solution on some interval.

TypeFormSolution Method
Separable$y'=g(t)h(y)$$\int dy/h(y)=\int g\,dt$
Linear$y'+p(t)y=q(t)$Integrating factor $e^{\int p}$
Logistic$y'=ry(1-y/K)$Partial fractions
Exact$M\,dt+N\,dy=0,\;M_y=N_t$Find potential $F$
Step 1 -- Separable: y = -y

Separate: $dy/y=-dt$. Integrate: $\ln|y|=-t+C$. Exponentiate: $y=y_0 e^{-t}$. With $y_0=1$: $y(t)=e^{-t}$. Check: $y'=-e^{-t}=-y$ ✓.

Step 2 -- Euler Method

$y_{n+1}=y_n+h\cdot f(t_n,y_n)$. Global error $O(h)$ -- halving $h$ halves the error. For $y'=-y$, $h=0.1$, $n=10$: $y_{10}=(0.9)^{10}=0.3487$ vs exact $e^{-1}=0.3679$. Error $=0.019$.

Step 3 -- Logistic Equation

$y'=y(1-y)$. Solution: $y(t)=1/(1+(1/y_0-1)e^{-t})$. Equilibria: $y=0$ (unstable), $y=1$ (stable). All solutions with $y_0>0$ converge to $y=1$ as $t o\infty$.

Step 4 -- Integrating Factor

For $y'+p(t)y=q(t)$: multiply by $\mu=e^{\int p\,dt}$. LHS becomes $(\mu y)'$. Integrate: $\mu y=\int \mu q\,dt+C$. Example: $y'+y=e^t$, $\mu=e^t$: $(e^t y)'=e^{2t}$, so $y=e^t/2+Ce^{-t}$.

Step 5 -- Direction Field

At each $(t,y)$, draw a slope segment of slope $f(t,y)$. Solution curves are tangent to all segments. Stable equilibria attract nearby curves; unstable repel. The simulation shows all solutions simultaneously.

Step 6 -- Picard Iteration

Convert IVP to integral equation: $y=y_0+\int_{t_0}^t f(s,y(s))\,ds$. Define iterates $y_{n+1}=y_0+\int f(s,y_n)\,ds$. For Lipschitz $f$, this converges uniformly. Provides existence proof and theoretical basis for numerical methods.

Reference: Boyce & DiPrima -- Elementary Differential Equations, 10th ed., Ch.1-2; Strogatz -- Nonlinear Dynamics Ch.2; MIT OCW 18.03.

❓ Section 4 -- FAQ

🧮Conceptual  What does the direction field show?

At each $(t,y)$ the slope $f(t,y)$ is drawn as a short line segment. Solution curves are everywhere tangent to these segments -- they "flow" along the field. Equilibria (where $f=0$) appear as horizontal segments. The field shows all solutions globally without solving the ODE explicitly.

Key takeaway: direction field = visual map of all solution slopes. Stable equilibria attract nearby curves.
🔬Simulation  What does Euler Method mode show?

The blue staircase path shows Euler steps vs the gold exact solution. The step size $h$ controls accuracy. The error graph shows $|y_{ m Euler}(T)-y_{ m exact}(T)|$ vs $h$ on log-log scale with slope $pprox 1$ -- confirming first-order convergence.

Key takeaway: Euler error ~ h (first-order). Log-log error graph has slope 1.
🌍Applied  Where do first-order ODEs appear?

Radioactive decay ($dN/dt=-\lambda N$), drug pharmacokinetics, population logistic growth, Newton cooling ($dT/dt=-k(T-T_{ m env})$), RC circuits ($dV/dt=-V/(RC)$), compound interest ($dA/dt=rA$), epidemic SIR model (coupled ODEs).

Key takeaway: decay, drug clearance, logistic growth, RC circuits, compound interest -- all first-order ODEs.
💡Non-Obvious  Does Euler's method always converge as h goes to 0?

For Lipschitz $f$, Euler converges with error $O(h)$. But for stiff ODEs (e.g., $y'=-1000y$), explicit Euler requires $h<0.002$ for stability -- impractically small. Implicit methods (Backward Euler, Crank-Nicolson) handle stiffness with large steps. RK4 needs only $h<0.002$ for accuracy but also suffers stability issues with stiffness.

Key takeaway: Euler converges for Lipschitz f but fails for stiff ODEs. Implicit methods handle stiffness.
📐Computational  Euler for y = 2ty, y(0)=1, h=0.1 at t=0.3.

$k_0=f(0,1)=0$, $y_1=1$. $k_1=f(0.1,1)=0.2$, $y_2=1.02$. $k_2=f(0.2,1.02)=0.408$, $y_3=1.0609$. Exact: $y=e^{t^2}$, $y(0.3)=e^{0.09}=1.0942$. Error $=0.033$. With $h=0.01$: error $pprox0.0033$ -- confirms first-order convergence.

Key takeaway: halving h halves the Euler error -- first-order convergence confirmed.
🎓Deep  What is the Picard iteration and why does it prove existence?

Convert IVP to $y=y_0+\int f(s,y(s))\,ds$ (integral equation). Picard iterates $y_{n+1}=y_0+\int f(s,y_n)\,ds$ converge since $T[y]=y_0+\int f(\cdot,y)$ is a contraction in $C[t_0,t_0+\delta]$ (sup norm) when $f$ is Lipschitz. Banach fixed-point theorem guarantees a unique fixed point = the solution. The same argument proves uniqueness.

Key takeaway: Picard iteration is a contraction mapping; Banach fixed-point theorem gives unique existence.
Best resources: 3Blue1Brown -- Differential equations; MIT OCW 18.03; Strogatz -- Nonlinear Dynamics; Paul's Online Math Notes.

⚠️ Section 5 -- Misconceptions & Common Errors

A · Conceptual Misconceptions
❌ Misconception: Every ODE has a closed-form solution.✅ Correction: Most ODEs have no elementary solution. $y'=e^{-t^2}$ cannot be integrated in closed form. Picard guarantees existence not a formula. Numerical methods compute solutions without formulas.📖 Boyce & DiPrima §2.1.
❌ Misconception: A direction field shows where solutions go -- just follow arrows.✅ Correction: Follow the slope (direction) of each segment, not the arrow's endpoint. The solution curve is tangent to segments at each point -- tracing a smooth curve through matching slopes.📖 Boyce & DiPrima §1.1.
❌ Misconception: Euler method is accurate enough for practical use.✅ Correction: Euler is a teaching tool -- order 1. RK4 (order 4) requires only 4x more work but error is $h^3$ times smaller. For $h=0.1$: RK4 error $\sim10^{-4}$ vs Euler $\sim10^{-1}$ -- 1000x improvement.📖 Burden & Faires -- Numerical Analysis §5.2.
B · Common Procedural Errors
❌ Error: Solving y = 2y by writing y = 2y*t + C.✅ Correct: Separate: $dy/y=2\,dt$. Integrate: $\ln|y|=2t+C$. Exponentiate: $y=Ae^{2t}$. Must separate variables first.🔍 Why: students treat $y'=2y$ as algebraic and integrate both sides directly without separating.
❌ Error: Euler step y_{n+1} = y_n + h*f(t_{n+1}, y_n).✅ Correct: $y_{n+1}=y_n+h\cdot f(t_n,y_n)$ -- evaluate $f$ at current time $t_n$, not next time $t_{n+1}$.🔍 Why: students confuse forward (explicit) Euler with other methods that use $t_{n+1}$.
❌ Error: For y + 3y = 6, trying to separate directly.✅ Correct: First rewrite as $y'=6-3y$, then separate: $dy/(6-3y)=dt$. Integrate: $- rac{1}{3}\ln|6-3y|=t+C$. Always rearrange to $y'=f(t,y)$ first.🔍 Why: students attempt to separate without isolating $y'$ first.
Education research: Rasmussen, C. & Kwon, O. -- An inquiry-oriented approach to undergraduate ODE, JMTE 10(1) (2007).