Finding localised solutions of a nonlinear boundary-value problem

Shooting, Newton–Kantorovich iteration and the limits of numerical convergence

A boundary condition at infinity is awkward to impose on a computer. In this investigation I looked for radially symmetric, localised solutions of a nonlinear differential equation, comparing two ways of turning that requirement into a finite calculation: shooting from the origin and solving a discretised Newton–Kantorovich correction problem.

I was interested in two different solution shapes—a monotonic profile and a profile with one node—and in how the methods behaved when I changed the domain, resolution and nonlinear parameter. The comparison showed why a solver’s stopping condition is only one part of assessing a numerical solution.

The problem

The equation is

\[v''(r)+\frac1r v'(r)-v(r)+2v(r)^3-\alpha v(r)^4=0,\]

with

\[v'(0)=0,\qquad v(r)\longrightarrow0\quad\text{as }r\longrightarrow\infty.\]

The origin is singular in the written form because of \(v'/r\). In the computation I started at \(\varepsilon=10^{-6}\) and replaced the infinite interval with \([\varepsilon,L]\), usually taking \(L=20\). The outer condition becomes \(v(L)=0\).

The two target branches are qualitatively different. The monotonic solution decreases towards zero without changing sign; the one-node solution crosses zero once before decaying. That distinction affects the bracket used for shooting and the initial guess used for Newton iteration.

Shooting: make the unknown central value a parameter

Writing \(w=v'\) converts the equation into

\[v'=w,\qquad w'=-\frac{w}{r}+v-2v^3+\alpha v^4.\]

I treated the initial value \(v(\varepsilon)=p\) as an unknown parameter and imposed \(w(\varepsilon)=0\). For each trial \(p\), MATLAB’s ode45 integrates to \(L\). The endpoint value defines a scalar residual,

\[R(p)=v(L;p).\]

The task is then to find a root of \(R\). I used bisection: integrate from the bracket midpoint, evaluate the endpoint residual, retain the subinterval with a sign change, and repeat until the endpoint tolerance is met or the maximum number of iterations is reached.

For the reported calculations, the initial bracket was \([1,3]\) for the monotonic solution and \([2,3]\) for the one-node solution, with tolerance \(10^{-8}\) and a maximum of \(100\) iterations.

% Differential system used by the shooting calculation.
function dydr = ode_system(r,y,alpha)
    dydr = [y(2); -y(2)/r + y(1) ...
        -2*y(1)^3 + alpha*y(1)^4];
end

% Endpoint residual: p is the trial initial displacement.
function err = endpoint_error(p,alpha,eps,L)
    [~,Y] = ode45(@(r,y) ode_system(r,y,alpha), ...
        [eps L],[p;0]);
    err = Y(end,1);
end

These are readable extracts of the source’s system and residual calculation; function names have been made descriptive. The bisection logic is

p_left = 2; p_right = 3;   % one-node bracket in the appendix
for iteration = 1:100
    p_mid = (p_left+p_right)/2;
    e_mid = endpoint_error(p_mid,alpha,eps,L);
    if abs(e_mid) < 1e-8
        break
    end
    if endpoint_error(p_left,alpha,eps,L)*e_mid < 0
        p_right = p_mid;
    else
        p_left = p_mid;
    end
end

The advantage is conceptual simplicity: the nonlinear boundary-value problem is reduced to repeated initial-value solves. Its sensitivity is also clear. A trial trajectory can move far from the decaying branch before it reaches the outer boundary.

I also tried Newton’s root-finding method to update the shooting parameter. In the reported trials it was less robust than bisection: it produced oscillatory, multi-node profiles rather than the desired branches, even from guesses near the successful shooting values. That experience is why I used the bracketed method for the reported shooting results. This scalar Newton update is distinct from the profile-based Newton–Kantorovich method below.

Newton–Kantorovich: correct an entire profile

For the second approach I defined

\[F(v)=v''+\frac1r v'-v+2v^3-\alpha v^4.\]

At the current approximation \(v\), introduce a correction \(z\) and retain first-order terms:

\[F(v+z)\approx F(v)+F'(v)z,\]

where the Fréchet derivative is

\[F'(v)z=z''+\frac1r z'-z+6v^2z-4\alpha v^3z.\]

The correction therefore solves

\[z''+\frac1r z'+(-1+6v^2-4\alpha v^3)z=-F(v),\]

followed by \(v\leftarrow v+z\). This replaces one nonlinear problem with a sequence of linear boundary-value problems.

Discrete correction equations

For an interior point \(r_i\), central differences give

\[v'_i\approx\frac{v_{i+1}-v_{i-1}}{2h},\qquad v''_i\approx\frac{v_{i+1}-2v_i+v_{i-1}}{h^2}.\]

The matrix row for the correction has entries

\[ a_i=\frac1{h^2}-\frac1{2hr_i},\quad b_i=-\frac2{h^2}-1+6v_i^2-4\alpha v_i^3,\quad c_i=\frac1{h^2}+\frac1{2hr_i}, \]

and right-hand side

\[-\left[ \frac{v_{i+1}-2v_i+v_{i-1}}{h^2} +\frac{v_{i+1}-v_{i-1}}{2hr_i} -v_i+2v_i^3-\alpha v_i^4\right].\]

The first row imposes the derivative condition through a one-sided difference; the final row enforces the endpoint value. In the submitted implementation,

\[\frac{z_2-z_1}{h}=-\frac{v_2-v_1}{h},\qquad z_N=-v_N.\]

I solved the linear system and iterated until the largest correction was below \(10^{-8}\).

What the original MATLAB code does

The appendix uses \(N=2000\) and forms a dense matrix with zeros(N,N). Although the interior discretisation is tridiagonal, this implementation does not explicitly use a sparse tridiagonal storage format.

r = linspace(eps,L,N)';
h = L/N;                  % spacing expression in the submitted code
v = 2*(1-r.^2).*exp(-r);   % refined one-node initial guess
for iteration = 1:max_iter
    A = zeros(N,N);
    b = zeros(N,1);
    A(1,1) = -1/h; A(1,2) = 1/h;
    b(1) = -(v(2)-v(1))/h;
    for i = 2:N-1
        A(i,i-1) = 1/h^2 - 1/(2*h*r(i));
        A(i,i) = -2/h^2 - 1 + 6*v(i)^2 - 4*alpha*v(i)^3;
        A(i,i+1) = 1/h^2 + 1/(2*h*r(i));
        b(i) = -((v(i+1)-2*v(i)+v(i-1))/h^2 ...
            +(v(i+1)-v(i-1))/(2*h*r(i)) ...
            -v(i)+2*v(i)^3-alpha*v(i)^4);
    end
    A(N,N) = 1; b(N) = -v(N);
    delta = A\b;
    v = v+delta;
    if max(abs(delta)) < 1e-8
        break
    end
end

The two recovered solution profiles

For the baseline shooting calculation at \(\alpha=0\), the reported initial values were

Solution branch Reported shooting value \(p\) Reported shooting iterations
Monotonic 1.560931840848 48
One node 2.356370492159 43

Original Figure 1: monotonic localised solution at alpha = 0, comparing shooting and Newton–Kantorovich.

Original Figure 1: monotonic localised solution at alpha = 0, comparing shooting and Newton–Kantorovich.

Original Figure 2: one-node localised solution at alpha = 0, comparing shooting and Newton–Kantorovich.

Original Figure 2: one-node localised solution at alpha = 0, comparing shooting and Newton–Kantorovich.

Newton–Kantorovich reached the reported solutions in \(5\) iterations for the monotonic profile and \(8\) for the one-node profile. These are iteration counts, not elapsed-time measurements. A shooting iteration includes an initial-value integration; a Newton iteration includes matrix construction and a linear solve. The counts therefore show different convergence histories, not a measured runtime speed-up.

Resolution and domain length

I varied both the outer boundary and the number of grid points because convergence of the iteration alone can conceal a poor spatial approximation.

With shooting, increasing \(L\) from \(20\) to \(30\) retained the qualitative profile, but the report records an endpoint residual of order \(10^{-4}\) rather than \(10^{-8}\). This illustrates the sensitivity of a long initial-value integration near a decaying solution.

For Newton–Kantorovich, a grid with \(N=50\) could satisfy the iteration’s convergence criterion while producing a visibly unsmooth profile. The source code’s \(N=2000\) is a much finer representation. The report also describes satisfactory behaviour out to \(L=300\) and a qualitatively similar profile at \(L=500\).

Original Figure 3: central value p against alpha on the monotonic branch; both methods are shown.

Original Figure 3: central value p against alpha on the monotonic branch; both methods are shown.

Original Figure 4: central value p against alpha on the one-node branch; both methods are shown.

Original Figure 4: central value p against alpha on the one-node branch; both methods are shown.

Shooting tests the endpoint residual \(|v(L)|\); the Newton code tests the largest update \(\max_i|\delta_i|\). A small update and a small boundary residual are different checks, even when both are useful.

Continuing the nonlinear parameter

I also explored how far each branch could be followed as \(\alpha\) changed. The procedure varied \(\alpha\), initially using increments of \(0.5\), and reduced the step when the solution changed qualitatively or a solve failed.

The following table summarises the numerical continuation results:

Method and branch Reported continuation in \(\alpha\)
Shooting, monotonic \([-20000,\,0.87]\)
Shooting, one node \([-0.9,\,0.87]\)
Newton–Kantorovich, monotonic \([-20000,\,0.87]\)
Newton–Kantorovich, one node Tracked down to \(-0.90\)

At the large negative end of the monotonic shooting exploration, the report gives an initial value of approximately \(p=0.0759\). These are numerical continuation results for the chosen brackets, guesses and stopping criteria, not proofs of existence intervals.

The initial guess was important for Newton iteration. The report begins with a one-node shape proportional to \((1-r^2)e^{-r}\) and later uses the refined guess \(2(1-r^2)e^{-r}\) in the appendix. For the monotonic branch, \(e^{-r}\) reached an incorrect branch in the reported test, whereas \(2e^{-r}\) produced the desired solution. For the one-node branch, \((1-r)e^{-r}\) failed while \(2(1-r^2)e^{-r}\) succeeded. Those tests show that both amplitude and profile shape matter, not merely the presence of a zero crossing.

What I took from the comparison

Shooting gives a direct interpretation of the unknown central value, while Newton–Kantorovich treats the entire profile as the object to improve. Their difficulties appear in different places: long-distance sensitivity in the initial-value solve, versus dependence on the starting profile, grid and linear-system implementation in the correction method.

The most useful outcome was a more demanding definition of a successful computation. I needed a plausible branch shape, appropriate boundary behaviour, sufficient spatial resolution and an interpretable residual—not just an iteration counter that stopped.

Originally completed as part of MAM3042F · Advanced Numerical Methods, University of Cape Town, 2026.