Chapter 10
Boundary Value Problems for Ordinary Differential Equations
These programs solve boundary value problems with shooting and finite differences, and find eigenvalues with Numerov shooting and a matrix method. Each program is available in MATLAB, Python, C++, and Fortran. Problem data and equations are easy to change. All programs print and save solution data; MATLAB and Python also plot the results.
The supplied examples include analytic comparisons to check the results. When changing a problem, replace or disable the exact-solution comparison and check accuracy by refining the grid or tightening tolerances. The Chapter 10 resources provide benchmarks and guidance on choosing a method.
Chapter 10 exercises & projects Chapter 10 resources Chapter 10 updates & errata Chapter 10 overview
| Program | MATLAB | Python | C++ | Fortran |
|---|---|---|---|---|
| 0. Shooting for a second-order ODEFinds the unknown initial slope with secant iteration; each trial uses adaptive Fehlberg RKF45. The example y″ = y has an analytic solution. | Download | Download | Download | Download |
| 1. Linear finite differencesDiscretizes y″ + p(x)y′ + q(x)y = r(x) with fixed endpoint values and solves the interior tridiagonal system with the Thomas algorithm. | Download | Download | Download | Download |
| 2. Boundary-condition choicesSolves a rod-conduction example with fixed values, a derivative at either end, or a right Robin condition. The other endpoint value is fixed when using a derivative or Robin condition. | Download | Download | Download | Download |
| 3. Nonlinear finite differencesSolves y″ = f(x,y,y′) by Newton iteration; analytic partial derivatives form each tridiagonal correction system. A manufactured exact solution checks accuracy. | Download | Download | Download | Download |
| 4. Eigenvalues by Numerov shootingScans endpoint sign changes, refines each eigenvalue with bisection, and normalizes the modes of a uniform string. Uses zero-value boundaries at both ends and no first-derivative term. | Download | Download | Download | Download |
| 5. Schrödinger matrix eigenvaluesBuilds the interior finite-difference Hamiltonian and uses symmetric Jacobi rotations. Outputs the lowest energies and normalized wavefunctions for a harmonic oscillator. Edit V(x) to study another potential. | Download | Download | Download | Download |