Kreyszig, Chapters 1–2

First-Order ODEs

The equations that describe how everything changes. From population growth to cooling coffee, it all starts here.

Prerequisites: Basic calculus (derivatives, integrals). That's it.
10
Chapters
6+
Simulations
10
Quizzes

Chapter 0: Why Differential Equations?

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:

dT/dt = −k(T − 20)

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.

The core idea: Nature speaks in derivatives. Velocities, reaction rates, current flow, population growth — they all describe how things change. An ODE captures this "rate of change" language and lets us predict the future from the present.

ODEs appear everywhere in engineering:

FieldODE describes
MechanicsF = ma (position, velocity, acceleration)
CircuitsV = L dI/dt (inductor voltage)
ChemistrydC/dt = −kC (reaction kinetics)
BiologydP/dt = rP (population growth)
ThermaldT/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.

What makes Newton's cooling law a first-order ODE?

Chapter 1: Direction Fields

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.

Key insight: A direction field is like a current in a river. Drop a leaf (an initial condition) anywhere, and the current carries it along a specific path. The ODE defines the current; the initial condition picks which path.
Direction Field Explorer

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.

What does a direction field show?

Chapter 2: Separable Equations

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:

dy/dx = g(x) · h(y)

Divide both sides by h(y) and multiply by dx:

(1/h(y)) dy = g(x) 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.

Example — Exponential growth: dy/dx = 2y. Separate: (1/y)dy = 2dx. Integrate: ln|y| = 2x + C. Exponentiate: y = Ae2x. The constant A is determined by the initial condition.

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.

Separable ODE Solutions

Adjust the parameters to see how the exponential decay/growth solution changes. Orange: solution curve. Teal dashed: equilibrium.

k (rate)1.0
y(0)3.0
What is the key step in solving a separable ODE?

Chapter 3: Linear First-Order ODEs

A linear first-order ODE has the standard form:

dy/dx + P(x)y = Q(x)

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 μ:

μy' + μPy = μQ

The left side is secretly a product rule: it equals d(μy)/dx. So the equation becomes:

d(μy)/dx = μ(x)Q(x)

Integrate both sides: μy = ∫μQ dx + C. Then divide by μ to get y. The integrating factor collapses the equation into a single integration step.

Why does the integrating factor work? Because e∫P dx is specifically chosen so that the product rule d(μy)/dx = μy' + μPy matches the left side of the equation. It is reverse-engineering the product rule.
Step 1
Write in standard form: y' + P(x)y = Q(x)
Step 2
Compute μ(x) = e∫P(x)dx
Step 3
Multiply: d(μy)/dx = μQ
Step 4
Integrate: y = (1/μ) ∫μQ dx + C/μ
Example: y' + 2y = 6ex. Here P = 2, Q = 6ex. Integrating factor: μ = e2x. Multiply: d(e2xy)/dx = 6e3x. Integrate: e2xy = 2e3x + C. Solution: y = 2ex + Ce−2x.
What is the integrating factor for y' + 3y = sin(x)?

Chapter 4: Exact ODEs

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:

∂F/∂x = M    and    ∂F/∂y = N

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.

The exactness test: The equation is exact if and only if ∂M/∂y = ∂N/∂x. This comes from the equality of mixed partial derivatives: ∂2F/∂y∂x = ∂2F/∂x∂y.

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.

How do you test whether M dx + N dy = 0 is exact?

Chapter 5: Existence & Uniqueness

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:

Existence & Uniqueness Theorem: If f(x, y) is continuous in a rectangle around (x0, y0), and ∂f/∂y is also continuous there, then the IVP y' = f(x, y), y(x0) = y0 has a unique solution in some interval around x0.

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.

What guarantees a unique solution to y' = f(x,y), y(x0) = y0?

Chapter 6: Euler's Method

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:

yn+1 = yn + h · f(xn, yn)

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.

Think of it this way: Euler's method is GPS navigation for ODEs. At each step, you look at the direction field, step in that direction for a small distance, look again, and adjust. Smaller steps = more accurate, but more work.
Euler's Method Visualizer

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).

Step size h0.50

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.

In Euler's method, what happens as you decrease the step size h?

Chapter 7: Applications

First-order ODEs model a stunning variety of physical phenomena. Here are the greatest hits from Kreyszig.

Exponential Growth and Decay

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.

Newton's Law of Cooling

dT/dt = −k(T − Tenv). The solution is T(t) = Tenv + (T0 − Tenv)e−kt. Temperature approaches the environment exponentially.

Mixing Problems

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.

RC Circuits

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.

Pattern: All these applications share the same mathematical structure: y' = −ky + (const). The solutions are always exponential approach to an equilibrium. Once you recognize the pattern, you can solve new problems instantly.
In an RC circuit with time constant τ = RC, what fraction of the final voltage is reached at t = τ?

Chapter 8: ODE Laboratory

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.

Full ODE Sandbox

Select an ODE. Click on the field to drop initial conditions. Adjust step size to see accuracy trade-offs. Multiple curves persist until cleared.

Step size h0.05
Steps200
Click on the field to add a solution curve.

Chapter 9: Connections

First-order ODEs are the foundation. Everything that follows builds on the intuitions you have developed here.

This lessonWhere it leads
Direction fieldsPhase portraits for systems of ODEs (Ch 2)
Integrating factorsLaplace transforms provide an algebraic alternative (Ch 3)
Euler's methodRunge-Kutta, Adams-Bashforth, stiff solvers
Exponential solutionsEigenvalue methods for systems (Ch 4)
Separable equationsSeparation of variables for PDEs (Ch 6)
Limitations: First-order ODEs describe systems with one degree of freedom. Real engineering systems — vibrating structures, coupled circuits, robot arms — need second-order ODEs and systems. That is next.

"The sciences do not try to explain, they hardly even try to interpret, they mainly make models." — John von Neumann

Which method from this lesson directly extends to solving PDEs?