CPBS 7620 - Lecture 16 - Differential Equations
Overview
Nicholas Dwork introduces ordinary differential equations (ODEs) and numerical methods for solving them, using a rainwater basin with initial height h(0) = 1 to illustrate time-stepping. He compares forward and backward Euler, central differences and leapfrog, then develops RK2 and RK4 as more accurate methods that trade additional function evaluations for improved estimates. Finally, he shows how to rewrite a higher-order ODE as a first-order system by collecting the unknown function and its derivatives into a vector.
Key takeaways
- Forward Euler advances an ODE solution using the derivative at the current point, while backward Euler depends on the next point and may require solving an implicit equation.
- Backward Euler can remain close to an exact solution in a case where forward Euler becomes unstable, illustrating that solver stability can matter more than update simplicity.
- Central differences can give a better derivative estimate than one-sided differences, but the leapfrog update needs two prior time values and can develop divergent oscillations.
- RK2 estimates the slope at a half-step and uses it for the full update, requiring two evaluations of F while basing the next result on the current state.
- RK4 combines four slope estimates (one at the start, two at the midpoint, and one at the endpoint) for a more accurate update at the cost of three additional evaluations of F compared with forward Euler.
- An nth-order ODE can be converted into a first-order vector system by making the function and its first n − 1 derivatives the components of the state.
Chapters
- An ODE contains derivatives; solving one means finding a function that satisfies the equation, either in closed form or numerically.
- A retention basin's water height changes with rainfall inflow and drain outflow; the example starts from h(0) = 1.
- Forward Euler approximates the derivative with a forward difference and uses the current height and time step Δt to calculate the next height.
- Backward Euler uses a backward difference, making the next height appear on both sides of the update; the example can be rearranged as a quadratic using z = √hₙ₊₁.
- Forward, backward, and central differences approximate derivatives; for a twice-differentiable function whose second derivative changes slowly, central difference is more accurate.
- Leapfrog applies a central-difference estimate but needs two previous values, h(t) and h(t − Δt); their oscillations can diverge, making the method unsuitable in some cases.
- RK2 takes a half-step with forward Euler, evaluates F at the estimated midpoint, and uses that slope for a full update based only on the current point.
- RK4 estimates slopes at the beginning, twice at the midpoint, and at the endpoint, then combines the four slopes in a weighted average; it uses three more F evaluations per update than forward Euler.
- Forward Euler, backward Euler, and Runge–Kutta methods are presented for first-order equations of the form y′(t) = f(t, y(t)).
- For an nth-order ODE, define x₁ = y, x₂ = y′, and continue through xₙ = y⁽ⁿ⁻¹⁾.
- Stack x₁ through xₙ into a vector X; the resulting equation for X′(t) is a first-order system that can be solved with the methods already described.
- The derivative of the vector-valued state X is treated as a Fréchet derivative.
Transcript excerpt
0:00 Hi, I'm Nicholas Twork, and in this lecture we'll discuss ordinary differential equations. An ordinary differential equation, or ODE, includes derivatives in the equation. So, for example, f''(x) + 2f'(x) + f(x) = e to the -kx. The goal of solving an ODE is to find a function that satisfies the expression. Much of the study of ODEs historically has focused on finding closed-form solutions for many classes of ODEs. For ODEs where we do not have a closed-form solution, we can still try to find solutions numerically. Let's look at an example. Suppose a retention basin collects rainwater. Water enters through the basin's opening in the top and leaves through a drain in the bottom.
0:48 For a basin of particular structure, it could be characterized using this ordinary differential equation. This first term contributes to the rate of change of height based on the amount of rainfall coming in, and this one takes away based on the amount of water draining. We need an initial condition, and for this case we'll say h(0) is equal to 1. To solve this numerically, we need an approximation of the derivative. And this is going to come from this now very familiar expression: h(t + Δt) is approximately equal to h(t) + h'(t) Δt. Solving for h'(t), we get h(t + Δt) - h(t) all over Δt. We can insert this approximation into our expression, and what we get is the forward Euler method. We can index time
1:37 as follows: t sub n is equal to n Δt for n = 0, 1, 2. And now we have an expression for the height at the next time, given the height at the current time. We know h sub 0, we know Δt, so we could find h sub 1, which lets us find h sub 2, etc.
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Nicholas Dwork.