🌡️Boundary Value Problems and Partial Differential Equations
Boundary Value Problems: Shooting and Finite Differences
Two-point BVPs, the shooting method, finite-difference discretisation, convergence and solve_bvp
Leiden, 1638
In his last book, Two New Sciences, Galileo asks how much load a beam can carry. He imagines a cantilever breaking at the wall and reasons about the resisting fibres of its cross-section — and gets the answer wrong by a factor of three, because he assumes every fibre pulls with the same force. It took more than a century, and the work of Jacob Bernoulli, Leonhard Euler and others, to arrive at the beam equation engineers still use: the bending moment is proportional to the curvature, and for a uniform beam under a distributed load ,
Four derivatives, so four conditions are needed. But they are not all given at one end. A beam clamped at the wall and resting on a support at the other has at the wall and (no deflection, no moment) at the support. A computer cannot simply start at one end and march — it does not know the slope and curvature it should leave the wall with.
This is a boundary value problem: the conditions are split between two boundaries, and the solution must satisfy all of them at once.
A two-point boundary value problem is an ODE on with conditions at both ends — fin temperatures with the base and the tip both specified, a cable sagging between two towers, the deflection of a beam, the steady concentration in a reactor with inlet and outlet conditions. Unlike initial value problems, BVPs may have no solution or many; for the linear problems of engineering there is usually exactly one. Two families of methods solve them.
Derivation
Where the fin and beam equations come from
The fin. Cut a thin slice of length from a fin of cross-section , perimeter and conductivity . Heat conducted in at one face minus heat conducted out at the other (Fourier's law, flux ) must equal heat lost through the slice's surface to the air (Newton's law of cooling, ) in steady state:
Its general solution is — the analytic answer the methods below are checked against, with fixed by the two end temperatures.
The beam. Bernoulli and Euler's law says the bending moment is proportional to the curvature, (with the deflection). Equilibrium of a short slice relates the moment, the shear force and the distributed load : and (with the usual sign conventions). Chain the three:
The boundary conditions come from the same quantities: a clamped end fixes and ; a pinned end and , i.e. ; a free end and , i.e. .
💡The shooting method
Turn the BVP into an IVP by guessing the missing initial conditions. For a fin, with and : guess the base slope , integrate to with an IVP solver (Unit 9), and measure the miss . Then solve with a root finder (Unit 2). For the fin with /m, slopes of and °C/m miss by and °C;
brentq finds °C/m, matching the analytic / solution to all digits shown.
Shooting is natural and reuses good IVP solvers. Its weakness: if the ODE has growing solutions, small changes in produce enormous changes at the far end and the root finding becomes ill-conditioned — at large the shots diverge violently. Multiple shooting splits the interval and matches at interior points.Derivation
Why the fin's miss is a straight line in — and why shooting can blow up
The fin equation is linear, so the solution started with slope is a fixed combination of two solutions: one with , , and one with , , scaled by . In the exact solution the second is . So
a straight line in . The secant method finds its root in a single step from any two shots — which is why two misses are enough in the lab, and
brentq agrees to all digits.The slope of that line is also the warning. A change in the starting slope changes the far end by , which grows like : every extra unit of multiplies the sensitivity by , so going from to multiplies it by about . The root-finding problem becomes ill-conditioned (lesson 1-4) — not because of the root finder, but because the IVP amplifies everything. Finite differences impose both ends at once and never amplify anything.
💡Finite differences for BVPs
Replace derivatives by difference quotients (lesson 8-1) at the interior grid points. For the fin:
with and moved to the right-hand side. That is a tridiagonal linear system — solved in by the Thomas algorithm (lesson 3-3). All the boundary conditions are imposed at once; nothing is guessed. The error is : at the fin's midpoint, intervals give errors that fall by 3.99, 4.00, 4.00, 4.00 per halving. For nonlinear BVPs the algebraic system is nonlinear and is solved by Newton's method — whose Jacobian is again tridiagonal or banded.
📐A propped cantilever with solve_bvp
A 6 m beam, clamped at and pinned at , MN m², uniform load 20 kN/m. Write as four first-order equations for and give
scipy.integrate.solve_bvp the four conditions . It returns a maximum deflection of 3.5096 mm at m — exactly the textbook at from the clamp — and a fixed-end moment of 90.000 kN m . solve_bvp uses collocation: a piecewise polynomial that satisfies the ODE at chosen points in each interval, with Newton's method on the resulting system and automatic mesh refinement.Calculus systematically evades a great deal of numerical calculation.
💡Where you will use this
Structures: beam deflections, columns on elastic foundations, plate strips — and the stiffness method is the finite-difference idea in matrix form. Heat transfer: fins, walls with heat generation, insulation design. Geotechnics: piles under lateral load (beams on Winkler springs) and one-dimensional consolidation profiles. Optimal Guidance: optimal control problems lead to two-point BVPs for the state and costate, solved by shooting or collocation.
📚Further reading
- Uri Ascher, Robert Mattheij and Robert Russell, Numerical Solution of Boundary Value Problems for Ordinary Differential Equations (Prentice-Hall, 1988; SIAM Classics 1995) — shooting, multiple shooting, finite differences and collocation.
- Randall LeVeque, Finite Difference Methods for Ordinary and Partial Differential Equations (SIAM, 2007), chapter 2, 'Steady States and Boundary Value Problems'.
- Jacek Kierzenka and Lawrence Shampine, 'A BVP solver based on residual control and the MATLAB PSE', ACM Transactions on Mathematical Software 27(3), 299–316 (2001) — the algorithm inside
scipy.integrate.solve_bvp.
↓But there is a problem
A beam or a fin has one spatial coordinate and no time. Most engineering fields have more: temperature through a heat shield that changes from second to second, pore pressure in a clay layer squeezed under a new building over decades, the concentration of a pollutant spreading through an aquifer.
In 1947 John Crank and Phyllis Nicolson at Manchester published a careful method for exactly this kind of problem — heat conduction that changes in time — after finding that the obvious explicit approach forced absurdly small time steps. Their scheme became the textbook method for diffusion. It also turned out to hide a subtle flaw.