Skip to article frontmatterSkip to article content

Nonlinearity and boundary conditions

Collocation for nonlinear differential equations operates on the same principle as for linear problems: replace functions by vectors and replace derivatives by differentiation matrices. But because the differential equation is nonlinear, the resulting algebraic equations are as well. We will therefore need to use a quasi-Newton or similar method as part of the solution process.

We consider the TPBVP (10.1.1), reproduced here:

u(x)=ϕ(x,u,u),axb,g1(u(a),u(a))=0,g2(u(b),u(b))=0.\begin{split} u''(x) &= \phi(x,u,u'), \qquad a \le x \le b,\\ g_1(u(a),u'(a)) &= 0,\\ g_2(u(b),u'(b)) &= 0. \end{split}

As in Collocation for linear problems, the function u(x)u(x) is replaced by a vector u\mathbf{u} of its approximated values at nodes x0,x1,,xnx_0,x_1,\ldots,x_n (see Equation (10.4.2)). We define derivatives of the sampled function as in (10.4.3) and (10.4.4), using suitable differentiation matrices Dx\mathbf{D}_x and Dxx\mathbf{D}_{xx}.

The collocation equations, ignoring boundary conditions for now, are

Dxxur(u)=0,\mathbf{D}_{xx} \mathbf{u} - \mathbf{r}(\mathbf{u}) = \boldsymbol{0},

where

ri(u)=ϕ(xi,ui,ui),i=0,,n.r_i(\mathbf{u}) = \phi(x_i,u_i,u_i'), \qquad i=0,\ldots,n.

and u=Dxu\mathbf{u}'=\mathbf{D}_x\mathbf{u}.

We impose the boundary conditions in much the same way as in Collocation for linear problems. Again define the rectangular boundary removal matrix E\mathbf{E} as in (10.4.8), and replace the equations in those two rows by the boundary conditions:

f(u)=[E(Dxxur(u))g1(u0,u0)g2(un,un)]=0.\mathbf{f}(\mathbf{u}) = \begin{bmatrix} \mathbf{E} \bigl( \mathbf{D}_{xx}\mathbf{u} - \mathbf{r}(\mathbf{u}) \bigr) \\[1mm] g_1(u_0,u_0') \\[1mm] g_2(u_n,u_n') \end{bmatrix} = \boldsymbol{0}.

The left-hand side of (10.5.4) is a nonlinear function of the unknowns in the vector u\mathbf{u}, so (10.5.4) is an (n+1)×1(n+1)\times 1 set of nonlinear equations, amenable to solution by the techniques of Chapter 4.

10.5.1Implementation

Our implementation using second-order finite differences is Function 10.5.1. It’s surprisingly short, considering how general it is, because we have laid a lot of groundwork already.

In order to solve a particular problem, we must write a function that computes ϕ for vector-valued inputs x\mathbf{x}, u\mathbf{u}, and u\mathbf{u}', and functions for the boundary conditions. We also have to supply init, which is an estimate of the solution used to initialize the quasi-Newton iteration. Since this argument is a vector of length n+1n+1, it sets the value of nn in the discretization.

The initial solution estimate can strongly influence how quickly a solution is found, or whether the quasi-Newton iteration converges at all. In situations where multiple solutions exist, the initialization can determine which is found.

10.5.2Parameter continuation

Sometimes the best way to get a useful initialization is to use the solution of a related easier problem, a technique known as parameter continuation. In this approach, one solves the problem at an easy parameter value, and gradually changes the parameter value to the desired value. After each change, the most recent solution is used to initialize the iteration at the new parameter value.

10.5.3Exercises

  1. ✍ This exercise is about the nonlinear boundary-value problem

    u=3(u)2u,u(1)=1,  u(2)=12.u'' = \frac{3(u')^2}{u} , \quad u(-1) = 1, \; u(2) = \frac{1}{2}.

    (a) Verify that the exact solution is u(x)=(x+2)1/2u(x) = ( x+2 )^{-1/2}.

    (b) Write out the finite-difference approximation (10.5.4) with a single interior point (n=2n=2).

    (c) Solve the equation of part (b) for the lone interior value u1u_1.

  2. (a) Use Function 10.5.1 to solve the problem of Exercise 1 for n=80n=80. In a 2-by-1 subplot array, plot the finite-difference solution and its error.

    (b) ⌨ For each n=10,20,40,,640n=10,20,40,\ldots,640, find the infinity norm of the error on the same problem. Make a log-log plot of error versus nn and include a graphical comparison to second-order convergence.

  3. ⌨ (Adapted from Ascher & Petzold (1998).) Use Function 10.5.1 twice with n=200n=200 to solve

    u+eu+0.5=0,y(0)=y(1)=0,u'' + e^{u+0.5} = 0, \quad y(0) = y(1) = 0,

    with initializations 7sin(x)7 \sin(x) and 14sin(x)\frac{1}{4} \sin(x). Plot the solutions together on one graph.

  4. ⌨ Use Function 10.5.1 to compute the solution to the Allen–Cahn equation in Demo 10.5.4 with ϵ=0.02\epsilon=0.02. Determine numerically whether it is antisymmetric around the line x=0.5x=0.5---that is, whether u(1x)=u(x)u(1-x)=-u(x). You should supply evidence that your answer is independent of nn.

  5. ⌨ Consider the pendulum problem from Example 10.1.1 with g=L=1g=L=1. Suppose we want to release the pendulum from rest such that θ(5)=π/2\theta(5)=\pi/2. Use Function 10.5.1 with n=200n=200 to find one solution that passes through θ=0\theta=0, and another solution that does not. Plot θ(t)\theta(t) for both cases together.

  6. ⌨ The BVP

    u=xsign(1x)u,u(6)=1,  u(6)=0,u'' = x \operatorname{sign}(1-x) u, \quad u(-6)=1, \; u'(6)=0,

    forces uu'' to be discontinuous at x=1x=1, so finite differences may not converge to the solution at their nominal order of accuracy.

    (a) Solve the problem using Function 10.5.1 with n=1400n=1400, and make a plot of the solution. Store the value at x=6x=6 for use as a reference high-accuracy solution.

    (b) For each n=100,200,300,,1000n=100,200,300,\ldots,1000, apply Function 10.5.1, and compute the error at x=6x=6. Compare the convergence graphically to second order.

  7. ⌨ The following nonlinear BVP was proposed by Carrier (for the special case b=1b=1 in Carrier (1970)):

    ϵu+2(1x2)u+u2=1,u(1)=u(1)=0.\epsilon u'' + 2(1-x^2)u +u^2 = 1, \quad u(-1) = u(1) = 0.

    In order to balance the different components of the residual, it’s best to implement each boundary condition numerically as u/ϵ=0u/\epsilon=0.

    (a) Use Function 10.5.1 to solve the problem with ϵ=0.003\epsilon=0.003, n=200n=200, and an initial estimate of all zeros. Plot the result; you should get a solution with 9 local maxima.

    (b) Starting with the result from part (a) as an initialization, continue the parameter through the sequence

    ϵ=3×103,3×102.8,3×102.6,,3×101.\epsilon = 3\times 10^{-3}, 3\times 10^{-2.8}, 3\times 10^{-2.6},\ldots, 3\times 10^{-1}.

    The most recent solution should be used as the initialization for each new value of ε. Plot the end result for ϵ=0.3\epsilon=0.3; it should have one interior local maximum.

    (c) Starting with the last solution of part (b), reverse the continuation steps to return to ϵ=0.003\epsilon=0.003. Plot the result, which is an entirely different solution from part (a).

  8. Demo 10.5.3 finds two solutions at λ=0.5\lambda=0.5. Continue both solutions by taking 50 steps from λ=0.5\lambda=0.5 to λ=0.79\lambda=0.79. Make a plot with λ on the horizontal axis and w(0)w(0) on the vertical axis, with one point to represent each solution found. You should get two paths that converge as λ approaches 0.79 from below.

References
  1. Ascher, U. M., & Petzold, L. R. (1998). Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations. Society for Industrial and Applied Mathematics.
  2. Carrier, G. F. (1970). Singular Perturbation Theory and Geophysics. SIAM Review, 12(2), 175–193. 10.1137/1012041