An initial-value solver needs the complete state at one time, which for a second-order equation means a value and a slope. A boundary-value problem gives one condition at each end of an interval instead, so the starting slope is unknown. Throughout, is the independent variable on an interval and . This lesson computes such problems in two ways, by adjusting the missing slope until the far boundary is met and by solving for the values on a whole grid at once, and it shows when neither method can single out an answer.
Key terms
Shooting method
Definition Consider the two-point boundary-value problem
The shooting method replaces the missing initial slope by a parameter and solves the initial-value problem with and , whose solution is written . It then adjusts until . When these initial-value problems have unique solutions that exist on all of , the solutions of the boundary-value problem correspond exactly to the slopes that hit the target, each solution belonging to its own slope . In practice each trial is integrated numerically, for example with an adaptive Runge-Kutta method, and a root-finding method chooses the next slope.
In plain words Guess the launch slope, integrate across the interval, see by how much the far boundary was missed, and correct the guess. The boundary problem becomes a sequence of initial-value problems plus a search for one number.
Example Take on with and . With the trial slope , integrating once gives , and integrating again with gives
The far value is , so the slope hits the target and the solution is . It satisfies every part of the problem, since , and . The trial with satisfies the equation and the left condition but ends at , which is why each condition has to be checked on its own.
Boundary residual
Definition For a trial slope , the boundary residual is the amount by which the trajectory misses the far condition,
Shooting is a search for the roots of . For a linear differential equation, is an affine function of , so two trial shots determine the root up to the integration error. For a nonlinear equation, bisection is reliable once two slopes with residuals of opposite signs are known. Newton’s method needs , and when has continuous partial derivatives and , it equals for the sensitivity , which solves
with the partial derivatives evaluated along . More generally, the boundary residual of any computed approximation is the amount by which it fails a boundary condition.
In plain words The residual is the miss distance at the far end, as a function of the launch slope. A zero miss means a solution, and the slope of the residual says how strongly the miss responds to a change of launch.
Example In the shooting example and for every . The sensitivity equation agrees, since with and gives , so . Because is affine, the two trials and already locate the root, since the line through the points and crosses zero at .
Finite-difference method
Definition Divide into equal steps of length with grid points . Let approximate at the interior points , and fix and from the boundary conditions. The finite-difference method replaces each derivative in the equation by a difference quotient at the grid points, here the centered second difference
and solves the resulting algebraic equations for all interior values at once. If has a continuous fourth derivative, adding the Taylor expansions of and cancels the odd terms and gives
for some between and . For the linear problem with and continuous and on , the discrete equations have exactly one solution for every , and when the true solution has a continuous fourth derivative the errors are at most a constant times .
In plain words Instead of firing trajectories, put unknown heights on a grid and require the equation to hold approximately at every interior point. Each equation ties a point to its two neighbors, and the boundary values enter as known numbers.
Example For on with zero boundary values, take . The grid is , with unknowns and . Each interior equation is
and multiplying by gives for . The solution, found in the next card, is . These are exactly the values of at the interior points, because a quadratic has and the error term vanishes. That exactness is special to this example. In general the grid is refined and the values are checked for convergence.
Tridiagonal system
Definition A tridiagonal system is a linear system whose matrix has nonzero entries only on the main diagonal and on the two diagonals next to it. A centered three-point difference produces such a system, because each grid equation involves only , and , and the known boundary values move to the right side. Gaussian elimination keeps this pattern and solves the system in a number of operations proportional to , a procedure often called the Thomas algorithm. It needs no row exchanges when is symmetric positive definite or strictly diagonally dominant. For with given boundary values, the matrix after multiplying by has on the diagonal and beside it, and it is symmetric positive definite.
In plain words Each unknown is linked only to its neighbors, so the matrix is empty except for a narrow band. Elimination sweeps down the band once and back up once, which is far cheaper than treating the matrix as full.
Example The finite-difference example leads to
Adding half of the first row to the second gives , and adding two thirds of this new row to the third gives . Back substitution then gives , then , then . Each row checks. The first gives , the second gives , and the third matches the first by symmetry.
Conditioning
Definition A problem is well conditioned when small changes in its data, such as boundary values, coefficients or small errors made during a computation, change its solution only by comparably small amounts, and ill conditioned when they can change it by much more. Conditioning belongs to the mathematical problem, or to a subproblem that an algorithm creates, not to the program. In shooting, if and , an error in the computed far value shifts the selected slope by about , so a nearly flat residual makes the slope ill conditioned. Shooting also suffers when its initial-value problems have a fast growing mode such as with large, because an error made near is multiplied by a factor that grows like as the integration proceeds toward . Shooting can then fail in floating-point arithmetic even though the boundary-value problem itself is well conditioned. Finite differences, or multiple shooting, which shoots across short subintervals and matches the pieces, avoid that long-range amplification.
In plain words Ask how much the answer moves when the data move a little. If the far end barely responds to the launch slope, a tiny miss at the far end leaves the slope very uncertain. If the far end responds violently, every small error made along the way is blown up.
Example In the shooting example , so an error of at moves the slope by about , and the matching is well conditioned. Now take on with , and . The trials are , so
The root is , and an error of in the far value moves it by about , roughly times the error. The residual is nearly flat because is close to , where uniqueness breaks down, as the next card shows. The opposite trouble appears for with and , whose solution stays between and . That boundary-value problem is well conditioned, since changing either boundary value by changes the solution by at most at every point. A change in the trial slope changes the far value by , so a slope error of , close to the spacing of double-precision numbers near , moves by about .
Nonunique boundary solutions
Definition A boundary-value problem has nonunique solutions when two different functions satisfy the differential equation and all the boundary conditions. Take a linear second-order equation with coefficients continuous on and two linear boundary conditions. Every solution of the equation has the form , with a particular solution and a fundamental pair of the homogeneous equation, and the boundary conditions become a linear system for and . If its matrix is invertible, the problem has exactly one solution. If the matrix is singular, the homogeneous problem, with zero forcing and zero boundary data, has a nonzero solution, and the original problem has either no solution or infinitely many. Nonlinear problems can also have several separate solutions, and a root finder then returns whichever one its starting guess leads to.
In plain words The data may fail to pin down one curve. A whole family can fit both ends, or no curve at all, and no algorithm can pick out an answer that the problem itself does not single out.
Example For on with , every function satisfies the equation and both boundary conditions. The trials are , so for every slope and shooting has nothing to select. Changing the equation to leaves no solution at all, because the general solution with forces , and then . The finite-difference system for the original problem is invertible for every and returns only , which hides the family. Its smallest eigenvalue in absolute value is about , so its condition number grows from about at to about at . A nearly singular matrix may be faithfully reporting a problem without a unique solution. For a nonlinear example, with has two solutions, with initial slopes and and largest values about and .
Check yourself
- Use shooting to solve on with and , and check the result against every part of the problem.
Show the answer
With and , integrating twice gives and
The residual is , so and . The checks are , and .
- Set up and solve the finite-difference equations for the problem of question 1 with . Compare the result with the exact solution and explain the agreement.
Show the answer
The grid is with and . Since and the right sides at the interior points are and , the two interior equations are
They reduce to and . The first gives , and substituting into the second gives , so and . The exact solution has and , the same values. The agreement is exact because is a cubic, so and the error term of the centered difference vanishes. A common slip is to drop the boundary value from the second equation, which would solve a problem with instead.
- For on with , and , find the boundary residual. For which does the problem have exactly one solution, and what happens at ?
Show the answer
The trials are , so
If , that is, if is not an integer multiple of , the residual has the single root and the unique solution is . If , then for every , so no slope works and the problem has no solution. The homogeneous problem with has the nonzero solutions at those values of , which is the singular case of the definition. Near the root is very large in absolute value and the residual is nearly flat, so the computed slope is ill conditioned even where a unique solution exists.