Topic

Boundary value problems

An initial value problem fixes y and y′ at one end. A boundary value problem fixes one condition at each end of an interval, and asks for the solution in between:

// y″ = −y, y(0) = 0, y(1) = 1
const s = bvp({ f: "-y", interval: [0, 1], left: { y: 0 }, right: { y: 1 } }).exact();
s.start;       // the slope y′(0), enclosed: 1/sin(1)
s.at("1/2");   // y(1/2), enclosed
s.unique;      // true: the equation is linear

f is the formula for y″ in x, y and dy (rename them with time and vars). Each condition is { y: value } or { dy: value }.

Shooting, with proof

One value at the left end is not given: the slope, when y(a) is. Call it s. For each s the initial value problem has a solution, and the right-hand condition is missed by some amount g(s). The preview finds a root of g in Float64, by the secant method on RK4 solves. The exact stage then:

  1. takes a small bracket [s₋, s₊] around that root;
  2. solves the initial value problem from s₋ and from s₊ with the validated solver (see Differential equations), and checks that the enclosures of g(s₋) and g(s₊) have opposite signs;
  3. solves once more from the whole bracket. If that solve reaches b, every solution starting in the bracket exists up to b, so g is continuous on the bracket.

By the intermediate value theorem, g has a root in the bracket: a solution of the boundary value problem exists, its left-end value lies in start, and the tube from step 3 encloses it at every x. If a bracket fails, a wider one is tried.

What is and is not claimed

For a linear equation g is a straight line, so the root is the only one and unique is true. For a nonlinear equation there may be other solutions with other slopes; the result is one solution, proven to exist, near the one the preview found. A different guess for the unknown value can lead to another. If the Float64 shooting does not converge, there is nothing to certify and the call refuses.

The cost is three validated solves. Linear problems take a fraction of a second. Nonlinear ones are slow over long intervals, because the validated solver is: the pendulum y″ = −sin y on [0, 1] takes about half a minute. Run them in a Worker and show the preview meanwhile.

Try itEdit the code and run it with @ratmath/analytic and Core's R, Rational, RationalInterval in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs