First-Order ODEs
The workhorse equations of engineering. Learn separable equations, homogeneous (y/x) equations, exact equations and integrating factors, linear first-order equations with the integrating factor e^∫P, Bernoulli equations, orthogonal trajectories, and applications: RC/RL circuits, Newton's cooling, mixing tanks, population growth and motion with drag — with an RK4 check.
A capacitor charging, a hot part cooling, a tank mixing and a skydiver slowing all obey first-order ODEs. Mastering their solution methods covers a large share of practical dynamic analysis.
An analogy
Solving a first-order ODE is like finding a route when you only know the compass bearing at every point — the method rewinds the bearings into a path.
Separable equations
Move all y terms to one side and x terms to the other, integrate both sides, then apply the initial condition. Watch for lost solutions when dividing (e.g. y = 0).
Linear equations
Multiply by μ = e^(∫P dx) so the left side becomes (μy)′. This handles time-varying inputs, e.g. RC circuits driven by ramps or sinusoids.
Exact, homogeneous and Bernoulli
Exact equations come from a potential F(x, y); an integrating factor may make an equation exact. Homogeneous equations use v = y/x. Bernoulli equations (drag ∝ v², logistic growth) become linear with v = y^(1−n).
Applications
RC: RC dv/dt + v = V_s; RL: L di/dt + Ri = V; cooling; mixing; logistic P′ = rP(1 − P/K); orthogonal trajectories (field lines ⟂ equipotentials).
Formulas
- Separable:
dy/dx = g(x)h(y) ⇒ ∫ dy/h(y) = ∫ g(x) dx - Linear:
y′ + P(x)y = Q(x); μ = e^(∫P dx); y = (1/μ)[∫ μQ dx + C] - Exact:
M dx + N dy = 0 with M_y = N_x ⇒ F(x, y) = C - Bernoulli:
y′ + Py = Qyⁿ; v = y^(1−n) makes it linear - Newton's cooling:
dT/dt = −k(T − T_a) ⇒ T = T_a + (T₀ − T_a)e^(−kt)
Worked example: Cooling constant
Given: Part at 90 °C in 20 °C air; 60 °C after 10 min
Find: k and time to reach 30 °C.
- 40 = 70e^(−10k) → k = ln(1.75)/10 = 0.0560 /min
- 10 = 70e^(−kt) → t = ln 7/k = 34.8 min
Answer: k = 0.056 /min; 34.8 min
Worked example: RL circuit
Given: L = 0.5 H, R = 10 Ω, V = 12 V, i(0) = 0
Find: i(t) and i(0.1 s).
- L i′ + Ri = V → i = (V/R)(1 − e^(−Rt/L))
- i = 1.2(1 − e^(−20t))
- i(0.1) = 1.2(1 − e⁻²) = 1.038 A
Answer: 1.04 A
RK4 check of Newton's law of cooling
import math
# Newton's law of cooling: dT/dt = -k (T - Ta)
k, Ta, T0 = 0.056, 20.0, 90.0
def f(t, T):
return -k * (T - Ta)
def rk4(f, t, y, h):
k1 = f(t, y)
k2 = f(t + h/2, y + h*k1/2)
k3 = f(t + h/2, y + h*k2/2)
k4 = f(t + h, y + h*k3)
return y + h * (k1 + 2*k2 + 2*k3 + k4) / 6
t, T, h = 0.0, T0, 1.0
while t < 30 - 1e-9:
T = rk4(f, t, T, h)
t += h
exact = Ta + (T0 - Ta) * math.exp(-k * 30)
print(f"RK4: T(30) = {T:.6f} C")
print(f"Exact: T(30) = {exact:.6f} C")
# RK4: T(30) = 33.046180 C
# Exact: T(30) = 33.046178 CComparing an analytic solution with a numerical one is the standard verification step: agreement to 6 digits confirms both the algebra and the code.
Common mistakes
- Wrong: Forgetting the constant before applying initial conditions. — Right: Add C when integrating, then solve for it.
- Wrong: Using μ = e^P instead of e^(∫P dx). — Right: Integrate P first.
Applications
- Electronics: RC/RL timing and filters.
- Thermal design: Cooling of parts and heat sinks.
- Process engineering: Mixing tanks and reactors.
Key takeaways
- Separable: split and integrate.
- Linear: μ = e^(∫P).
- Exact, homogeneous, Bernoulli techniques.
- Verify analytically and numerically.
Going further
- Riccati equations: y′ = P + Qy + Ry².
- Clairaut equations: Singular solutions.
- Numerical IVP solvers: Euler, RK4, adaptive steps (M9).