The equations that describe how everything changes. From population growth to cooling coffee, it all starts here.
A cup of coffee sits on your desk. It is 90 degrees Celsius. The room is 20 degrees. How fast does it cool? Newton's law of cooling says the rate of temperature change is proportional to the difference between the coffee's temperature and the room's temperature.
Write T for the coffee temperature and t for time. The statement "rate of change is proportional to the difference" translates directly into mathematics:
This is an ordinary differential equation (ODE): an equation relating an unknown function T(t) to its derivative dT/dt. The word "ordinary" means there is only one independent variable (time). The function T(t) that satisfies this equation is the solution.
ODEs appear everywhere in engineering:
| Field | ODE describes |
|---|---|
| Mechanics | F = ma (position, velocity, acceleration) |
| Circuits | V = L dI/dt (inductor voltage) |
| Chemistry | dC/dt = −kC (reaction kinetics) |
| Biology | dP/dt = rP (population growth) |
| Thermal | dT/dt = −k(T − Tenv) (cooling) |
The order of an ODE is the highest derivative that appears. Newton's cooling law has dT/dt (first derivative), so it is first-order. F = ma involves d2x/dt2 (second derivative), so it is second-order. This lesson covers first-order ODEs. The next lesson tackles second-order.
Before we solve an ODE analytically, let us see what the equation is telling us. Consider a general first-order ODE: dy/dx = f(x, y). At every point (x, y) in the plane, the right-hand side f(x, y) gives us the slope of the solution curve passing through that point.
If we draw a tiny line segment at each point with the slope that f prescribes, we get a direction field (also called a slope field). The solution curves must be tangent to these segments everywhere. You do not need to solve the ODE analytically to see the qualitative behavior of solutions.
Choose an ODE from the dropdown. Click anywhere on the canvas to drop an initial condition and watch the solution curve flow along the direction field.
Notice how different initial conditions produce different curves, but they all follow the field. Solutions never cross each other (as long as f is well-behaved). This is a consequence of the existence and uniqueness theorem, which we will formalize in Chapter 5.
The simplest first-order ODEs to solve are separable: you can rearrange so all the y stuff is on one side and all the x stuff is on the other. The general form is:
Divide both sides by h(y) and multiply by dx:
Now integrate both sides. The left side is a function of y alone; the right side is a function of x alone. This gives you an implicit solution.
Newton's cooling law dT/dt = −k(T − 20) is separable too. Let u = T − 20, so du/dt = −ku. Separate: (1/u)du = −k dt. Integrate: ln|u| = −kt + C. Solution: T(t) = 20 + (T0 − 20)e−kt. The coffee temperature decays exponentially toward room temperature.
Adjust the parameters to see how the exponential decay/growth solution changes. Orange: solution curve. Teal dashed: equilibrium.
A linear first-order ODE has the standard form:
The unknown y appears only to the first power (no y2, no sin(y)). This linearity is what makes these solvable by a systematic method.
The trick is the integrating factor μ(x) = e∫P(x)dx. Multiply the entire equation by μ:
The left side is secretly a product rule: it equals d(μy)/dx. So the equation becomes:
Integrate both sides: μy = ∫μQ dx + C. Then divide by μ to get y. The integrating factor collapses the equation into a single integration step.
Some first-order ODEs hide a deeper structure. Consider M(x,y)dx + N(x,y)dy = 0. This equation is exact if there exists a function F(x,y) such that:
If such an F exists, then the ODE is really dF = 0, meaning F(x,y) = C is the solution. The curves F(x,y) = C are called level curves of F.
Example: (2xy + 3)dx + (x2 − 1)dy = 0. Check: M = 2xy + 3, N = x2 − 1. ∂M/∂y = 2x, ∂N/∂x = 2x. Equal! So it is exact.
To find F: Integrate M with respect to x: F = x2y + 3x + g(y). Take ∂F/∂y = x2 + g'(y) = N = x2 − 1. So g'(y) = −1, giving g(y) = −y. Solution: x2y + 3x − y = C.
When the equation is not exact, you can sometimes find an integrating factor that makes it exact. If (∂M/∂y − ∂N/∂x)/N depends only on x, then μ(x) = e∫that function dx works. Similarly for a factor depending only on y.
We have been finding solutions, but can we always find one? And if we do, is it the only one? These are not academic questions. If an engineer designs a bridge based on an ODE that has no solution, or picks the wrong one of many solutions, things go badly.
The fundamental theorem for first-order ODEs (Picard-Lindelöf) says:
The two conditions matter separately. Continuity of f guarantees at least one solution exists. Continuity of ∂f/∂y guarantees the solution is unique.
Failure example: y' = y1/3, y(0) = 0. Here f = y1/3 is continuous, but ∂f/∂y = (1/3)y−2/3 blows up at y = 0. Indeed, this IVP has two solutions: y = 0 (the trivial one) and y = (2t/3)3/2. Without the uniqueness condition, you cannot trust that your solution is the only one.
Most ODEs in the real world cannot be solved with a nice formula. You need a numerical method. The simplest is Euler's method, and every more sophisticated method (Runge-Kutta, Adams-Bashforth) is a refinement of this same idea.
Given y' = f(x, y) with y(x0) = y0, pick a step size h. At each step, approximate the curve by its tangent line:
You know the slope at (xn, yn) — it is f(xn, yn). Walk along that tangent line for a distance h. That gives you the next point. Repeat.
Orange segments: Euler steps. Teal curve: exact solution. Reduce h to see convergence. The ODE is dy/dx = −y, y(0) = 3 (exact: y = 3e−x).
The error in Euler's method is proportional to h. Halve the step size and you halve the error (roughly). This is called a first-order method. The classic fourth-order Runge-Kutta method achieves error proportional to h4 — halving h cuts error by a factor of 16.
First-order ODEs model a stunning variety of physical phenomena. Here are the greatest hits from Kreyszig.
dP/dt = kP has solution P = P0ekt. If k > 0, population explodes. If k < 0, radioactive material decays. The half-life t1/2 = ln(2)/|k| is the time for the quantity to halve.
dT/dt = −k(T − Tenv). The solution is T(t) = Tenv + (T0 − Tenv)e−kt. Temperature approaches the environment exponentially.
A tank holds 100 liters of brine with 10 kg of dissolved salt. Fresh water flows in at 5 L/min, well-mixed brine flows out at 5 L/min. Let A(t) = kg of salt at time t. The ODE is dA/dt = −(5/100)A = −A/20. Solution: A(t) = 10e−t/20.
A resistor R in series with a capacitor C and voltage source E gives: RC dVc/dt + Vc = E. This is a linear first-order ODE with solution Vc(t) = E(1 − e−t/RC). The time constant τ = RC governs how fast the capacitor charges.
This is your full-featured ODE sandbox. Choose an equation, set initial conditions, and watch Euler's method trace the solution over a live direction field. You can compare step sizes, add multiple solution curves, and see how numerical errors accumulate.
Select an ODE. Click on the field to drop initial conditions. Adjust step size to see accuracy trade-offs. Multiple curves persist until cleared.
First-order ODEs are the foundation. Everything that follows builds on the intuitions you have developed here.
| This lesson | Where it leads |
|---|---|
| Direction fields | Phase portraits for systems of ODEs (Ch 2) |
| Integrating factors | Laplace transforms provide an algebraic alternative (Ch 3) |
| Euler's method | Runge-Kutta, Adams-Bashforth, stiff solvers |
| Exponential solutions | Eigenvalue methods for systems (Ch 4) |
| Separable equations | Separation of variables for PDEs (Ch 6) |
"The sciences do not try to explain, they hardly even try to interpret, they mainly make models." — John von Neumann