Module contents
Lesson 4 of 27Advanced 95 min

Nonlinear systems: numerical continuation and boundary value problems

Follow nonlinear equilibrium branches with pseudo-arclength continuation, detect bifurcations, and solve boundary-value and periodic-orbit problems.

After this lesson you can

  • Implement natural and pseudo-arclength continuation with tangent prediction and Newton correction.
  • Detect folds and branch bifurcations with determinant and eigenvalue test functions.
  • Solve boundary-value problems by single and multiple shooting and explain when single shooting fails.
  • Use solve_bvp collocation for boundary-value problems and periodic orbits.

Before you start

Following solutions

A reactor can have several steady states under the same cooling setting. As that setting changes, a stable branch can end at a fold and the state jump to another: a form of hysteresis. A buckling bridge and a biochemical oscillator also exhibit branches, although their equations and stability criteria differ. Integrating one initial condition can hide unstable equilibria and coexisting solutions.

Write the equilibrium condition as F(x,λ)=0F(x,\lambda)=0, with x∈Rnx\in\R^n and scalar parameter λ\lambda. If FxF_x is invertible, the implicit function theorem allows a local description x(λ)x(\lambda) and yields Fxx′(λ)+Fλ=0F_xx'(\lambda)+F_\lambda=0. Natural continuation increments λ\lambda and corrects xx using Newton’s method. At a fold, FxF_x becomes singular and that parameterization fails, even though the full curve may remain smooth.

Pseudo-arclength

Pseudo-arclength continuation treats z=(x,λ)z=(x,\lambda) as unknown. Given a point zkz_k and a unit tangent tkt_k in the null space of [Fx Fλ][F_x\ F_\lambda], predict zp=zk+Δs tkz_p=z_k+\Delta s\,t_k and correct with

F(x,λ)=0,tk⊤(z−zp)=0.F(x,\lambda)=0,\qquad t_k\T(z-z_p)=0.

The second equation fixes a hyperplane perpendicular to the previous tangent. Newton solves the augmented system; orient the new tangent so its inner product with the previous one is positive. A small step reduces the risk of jumping branches, but costs more corrections. If Newton fails, a practical implementation reduces the step and retries; the lab reports failure so it is visible.

In one iteration, if G(z)=(F(z),tk⊤(z−zp))G(z)=(F(z),t_k\T(z-z_p)), the correction satisfies

[FxFλtx⊤tλ][ΔxΔλ]=−G(z).\begin{bmatrix}F_x&F_\lambda\\ t_x\T&t_\lambda\end{bmatrix} \begin{bmatrix}\Delta x\\\Delta\lambda\end{bmatrix}=-G(z).

The predictor need not satisfy F=0F=0; the corrector must reduce both residual components. Pseudo-arclength is a local approximation to arc length, not the exact distance along an arbitrary curve. Scales of xx and λ\lambda matter: if one variable is millions of times larger than another, it can dominate the Euclidean norm and hyperplane. Nondimensionalize or choose explicit weights and keep them fixed when comparing steps.

InteractiveContinuation over the fold
  • Exact curve
  • Computed branch
  • Predictor

Reduced reactor: F=λ−θ+10q/(1+q), q=0.1 exp(12θ/(12+θ)). Natural continuation stops if Newton fails or jumps far from the previous branch.

Method
60
0.05
Accepted steps60
StatusCompleted
Residual2.49e-14
For a reduced reactor, compare advancing the parameter with tangent prediction and augmented correction. The orange point is the latest predictor and blue is the corrected solution.

The model is a reduced thermal balance F=λ−θ+10q/(1+q)F=\lambda-\theta+10q/(1+q), q=0.1e12θ/(12+θ)q=0.1e^{12\theta/(12+\theta)}, with relative temperature θ>−12\theta>-12. It can be obtained by eliminating steady-state concentration from a well-mixed reactor with one reaction and positive rate qq. Parameters are a dimensionless example, not plant measurements. The scalar equation describes reduced thermal equilibrium; stability of the full reactor requires analyzing all its dynamic variables.

To see the elimination, let cc be normalized concentration and suppose c˙=1−c−q(θ)c\dot c=1-c-q(\theta)c. At equilibrium c=1/(1+q)c=1/(1+q) and the reaction rate is q/(1+q)q/(1+q). A simplified thermal balance θ˙=λ−θ+10q(θ)c\dot\theta=\lambda-\theta+10q(\theta)c leads to the displayed expression after substituting that equilibrium. This reduction helps find steady points, but replacing a dynamic variable with its equilibrium value does not alone prove stability of the two-equation system.

If [Fx Fλ][F_x\ F_\lambda] has rank nn, its null space is one-dimensional and generated by tangent tt. At a regular fold FxF_x is singular, but the augmented matrix with final row t⊤t\T is invertible: a vector in its null space must be a multiple of tt by the first rows and orthogonal to tt by the last, hence zero.

Numerical bifurcation detection uses indicators and then locates and verifies the event. A sign change of a real eigenvalue, or a determinant passing through zero, can signal a fold or branch bifurcation; alone it does not distinguish them. In two dimensions, Hopf requires zero trace, positive determinant and transverse crossing of the complex pair. In higher dimensions follow the real part of an eigenvalue pair. A coarse grid can miss events: reduce the step and inspect eigenvectors.

For example, F(x,λ)=λx−x3F(x,\lambda)=\lambda x-x^3 has branch x=0x=0 for every λ\lambda and two branches x=±λx=\pm\sqrt\lambda when λ>0\lambda>0. At the origin, Fx=0F_x=0 and also Fλ=0F_\lambda=0: matrix [Fx Fλ][F_x\ F_\lambda] loses rank. This is not the regular fold from the previous proof. To switch branches construct a new seed in the critical direction and correct it; an isolated sign change does not automatically select that branch. As an alternative to recomputing the Jacobian each iteration, Broyden’s method updates an approximation, which must be monitored near singularities.

Shooting and collocation

In a boundary-value problem, conditions are known at different endpoints. Single shooting proposes unknown initial values, integrates an ODE and adjusts those values to meet final conditions. For y′′=100yy''=100y, y(0)=1y(0)=1, y(1)=0y(1)=0, a variation δ\delta in initial slope changes y(1)y(1) by δsinh⁡(10)/10\delta\sinh(10)/10. The factor is approximately 1101.3: a small error is amplified because a growing mode exists.

InteractiveShooting at an unstable target
  • Perturbed shooting
  • Boundary-value solution

Single shooting uses the perturbed exact slope; multiple shooting solves continuity and boundaries together. Amplification is local to one segment, not a guarantee about conditioning of the global system.

Method
8
4
Final value0.000011
Amplification per segment1101.3233
Change the slope error and divide the interval into segments. Multiple shooting solves continuity and boundaries together; the readout shows local amplification over one segment.

Multiple shooting introduces an unknown state at each node and requires each local integration to end at the next state. Shorter segments reduce growth within each integration, but the full continuity system may still be ill-conditioned. In the linear example that system is solved directly, equivalent to one exact Newton step; a nonlinear problem requires iteration and residual checks. Collocation approximates the whole solution with piecewise polynomials and fits the ODE residual and boundary conditions jointly. The solve_bvp documentation describes its adaptive mesh and conditions.

If Φi\Phi_i is flow through segment ii, continuity equations are Φi(yi)−yi+1=0\Phi_i(y_i)-y_{i+1}=0, together with endpoint conditions. Their Jacobian has sparse blocks: each equation involves only two consecutive nodes. The periodic cell uses exactly this structure, with the last node connected to the first. The local benefit appears when comparing sinh⁡(10/k)/10\sinh(10/k)/10 for each segment with sinh⁡(10)/10\sinh(10)/10 for the whole interval; that figure should not be multiplied or interpreted as the condition of the entire coupled matrix.

In collocation, a solution reported as converged still requires checking: inspect boundary residual, tolerance, node count and change under mesh refinement. Different seeds can converge to different solutions. This matters especially when an equilibrium and a cycle coexist, as in the next example.

Hopf and periodic orbits

The Brusselator is a two-variable reaction model:

x˙=A−(B+1)x+x2y,y˙=Bx−x2y.\dot x=A-(B+1)x+x^2y,\qquad \dot y=Bx-x^2y.

For A>0A>0, equilibrium is (A,B/A)(A,B/A) and its Jacobian has trace B−1−A2B-1-A^2 and determinant A2A^2. With A=1A=1, the imaginary pair crosses at B=2B=2. The figure calculates a cycle branch through numerical closure and phase, starting at B=2.3B=2.3 and using each solution as the next seed. Amplitude is maximum minus minimum of xx; discrete points do not prove cycle stability.

InteractiveBrusselator diagram
  • Stable equilibrium
  • Unstable equilibrium
  • Orbit amplitude

Equilibrium is shown at x=1 and the green branch represents maximum minus minimum x. Cycles solve closure with phase x(0)=1, RK4 and continuation in B; orbit stability is not inferred from the graph alone.

2.30
Equilibrium trace0.300
Determinant1
Equilibrium statusunstable
Nearest periodic point2.300
Cycle amplitude1.4424
Closure residual1.25e-10
The horizontal branch is equilibrium x=1, colored by stability. The amplitude curve uses shooting and numerical corrections, and the violet point marks the Hopf condition.

The periodic orbit of unknown period TT satisfies ϕT(x0)−x0=0\phi_T(x_0)-x_0=0. Shifting the time origin produces the same orbit and leaves a neutral direction. A phase condition removes that ambiguity; here we use x0=Ax_0=A and choose the nonconstant solution using a seed near the cycle. The condition does not eliminate constant equilibrium as an algebraic solution, so amplitude and period are also checked.

Floquet multipliers are eigenvalues of the fundamental matrix after one period. One is 1 due to the time direction of an autonomous cycle; transverse stability is decided by the others, not the neutral multiplier. Calculating them requires integrating the variational equation along the orbit and checking closure accuracy.

Closure ϕT(x0)−x0=0\phi_T(x_0)-x_0=0 has two components for the Brusselator and three unknowns: two initial coordinates and TT. Phase provides the third equation. Conversely, fixing an arbitrary period and adding a phase can overdetermine the problem. In the lab, the seed selects intersection x0=1x_0=1 corresponding to the desired branch; a section that is not transverse at the chosen point can make this phase condition unsuitable.

Lab: continuation and orbit

The first block implements prediction and correction for a square system with one parameter. The tangent comes from the null space by SVD. It returns accepted points and raises an error if Newton does not converge.

[ ]Pseudo-arclength continuationBrowser
import numpy as np
def pseudo_arclength(F,J,x0,lam0,ds,n,tol=1e-10,max_iter=12):
    x=np.atleast_1d(np.asarray(x0,dtype=float));z=np.r_[x,float(lam0)]
    if ds<=0 or n<0 or np.linalg.norm(F(x,lam0))>tol: raise ValueError('punto inicial o paso inválido')
    def tangent(point,previous=None):
        A,b=J(point[:-1],point[-1])
        _,_,V=np.linalg.svd(np.column_stack((A,np.asarray(b).reshape(-1))))
        t=V[-1]
        if previous is None and t[0]<0: t=-t
        if previous is not None and np.dot(t,previous)<0: t=-t
        return t
    t=tangent(z);branch=[z.copy()]
    for _ in range(n):
        pred=z+ds*t;q=pred.copy()
        for iteration in range(max_iter):
            f=np.asarray(F(q[:-1],q[-1]),dtype=float).reshape(-1)
            residual=np.r_[f,np.dot(t,q-pred)]
            if np.linalg.norm(residual,np.inf)<tol: break
            A,b=J(q[:-1],q[-1])
            aug=np.vstack((np.column_stack((A,np.asarray(b).reshape(-1))),t))
            q-=np.linalg.solve(aug,residual)
        else: raise RuntimeError('Newton no convergió; reduce el paso')
        t=tangent(q,t);z=q;branch.append(z.copy())
    return np.asarray(branch)
def cstr(x,lam):
    theta=x[0];q=.1*np.exp(12*theta/(12+theta))
    return np.array([lam-theta+10*q/(1+q)])
def cstr_jac(x,lam):
    theta=x[0];q=.1*np.exp(12*theta/(12+theta))
    return np.array([[-1+10*q/(1+q)**2*144/(12+theta)**2]]),np.array([1.])
[ ]Two folds of the reduced reactorBrowser
branch=pseudo_arclength(cstr,cstr_jac,[0.],-1/1.1,.05,160)
folds=np.flatnonzero(np.diff(np.sign(np.diff(branch[:,1]))))+1
print('retornos aproximados (θ, λ):',branch[folds])
print('residuo máximo:',max(abs(cstr([x],lam)[0]) for x,lam in branch))

Detection by sign changes in differences of λ\lambda locates only the step containing each fold; it is not a refined root. For Hopf, evaluate the trace and determinant of the analytical Brusselator Jacobian:

[ ]Hopf indicatorBrowser
def bruss_jac(x,B):
    u,v=x
    return np.array([[-(B+1)+2*u*v,u*u],[B-2*u*v,-u*u]])
for B in (1.8,2.,2.2):
    J=bruss_jac([1.,B],B)
    print('B, traza, determinante:',B,np.trace(J),np.linalg.det(J))

Construct three shooting segments with phase x(0)=1x(0)=1. Seed [1,3][1,3] and period 6.4 are approximations for A=1,B=2.3A=1,B=2.3; they are integrated to generate initial nodes. The corrector requires closure between segments and returns its residual.

[ ]Orbit by multiple shootingBrowser
import numpy as np
from scipy.integrate import solve_ivp
from scipy.optimize import root
A=1.; B=2.3; K=3
def bruss(y):
    u,v=y
    return np.array([A-(B+1)*u+u*u*v,B*u-u*u*v])
def flow(y,t):
    sol=solve_ivp(lambda t,y:bruss(y),(0,t),y,rtol=1e-8,atol=1e-10)
    if not sol.success: raise RuntimeError(sol.message)
    return sol.y[:,-1]
nodes=[np.array([1.,3.])]
for i in range(1,K): nodes.append(flow(nodes[-1],6.4/K))
def orbit_residual(z):
    T=z[-1]; pts=z[:-1].reshape(K,2)
    if T<=0: return np.full(2*K+1,1e6+abs(T))
    return np.r_[*[flow(pts[i],T/K)-pts[(i+1)%K] for i in range(K)],pts[0,0]-A]
fit=root(orbit_residual,np.r_[np.array(nodes).ravel(),6.4],tol=1e-9)
if not fit.success or np.linalg.norm(orbit_residual(fit.x),np.inf)>1e-7: raise RuntimeError('disparo no convergió')
orbit_fit=fit.x
print('periodo:',orbit_fit[-1],'estado inicial:',orbit_fit[:2])
print('residuo de cierre y fase:',np.linalg.norm(orbit_residual(orbit_fit),np.inf))

Collocation uses that orbit as seed, with rescaled time s=t/Ts=t/T. It imposes two periodic conditions and one phase condition for two components and unknown parameter TT.

[ ]Compare with collocationBrowser
from scipy.integrate import solve_ivp,solve_bvp
T=orbit_fit[-1];initial=orbit_fit[:2];mesh=np.linspace(0,1,81)
def bruss_bvp(y):
    u,v=y
    return np.array([1.-3.3*u+u*u*v,2.3*u-u*u*v])
sample=solve_ivp(lambda t,y:bruss_bvp(y),(0,T),initial,t_eval=mesh*T,rtol=1e-8,atol=1e-10)
def ode(s,y,p): return p[0]*bruss_bvp(y)
def bc(ya,yb,p): return np.r_[ya-yb,ya[0]-1.]
coll=solve_bvp(ode,bc,mesh,sample.y,p=[T],tol=1e-6)
if not coll.success: raise RuntimeError(coll.message)
print('periodos disparo y colocación:',T,coll.p[0])
print('diferencia de periodo:',abs(T-coll.p[0]),'amplitud x:',np.ptp(coll.y[0]))

Now integrate the variational system M˙=Df(x(t))M\dot M=Df(x(t))M, M(0)=IM(0)=I, over the period obtained by shooting. In this particular cycle, the multiplier close to one corresponds to phase and the other determines transverse stability.

[ ]Floquet multipliersBrowser
import numpy as np
from scipy.integrate import solve_ivp
period=orbit_fit[-1];start=orbit_fit[:2]
def floquet_rhs(t,z):
    u,v=z[:2];M=z[2:].reshape(2,2)
    field=np.array([1.-3.3*u+u*u*v,2.3*u-u*u*v])
    jac=np.array([[-3.3+2*u*v,u*u],[2.3-2*u*v,-u*u]])
    return np.r_[field,(jac@M).ravel()]
sol=solve_ivp(floquet_rhs,(0,period),np.r_[start,np.eye(2).ravel()],rtol=1e-9,atol=1e-11)
if not sol.success: raise RuntimeError(sol.message)
print('multiplicadores:',np.linalg.eigvals(sol.y[2:,-1].reshape(2,2)))
print('cierre de la órbita:',np.linalg.norm(sol.y[:2,-1]-start))

The comparison shares the same seed and equation: it checks agreement in this case, not convergence for every parameter. Tools such as AUTO-07p, MatCont and BifurcationKit incorporate additional strategies; they are not run here.

Exercises

ProofThe corrector at a fold
Prove: Show that the augmented matrix is invertible on a regular curve.
0
M=[F_x F_λ] has rank n and its null space is generated by a unit tangent t.

Step 1 of 3. What form does a vector w with Mw=0 have?

NumericShooting sensitivity
For y''=100y, what factor multiplies an error in y'(0) when it reaches y(1)?
CodeCross two folds
Implement pseudo_arclength(F, J, x0, lam0, ds, n) using an SVD tangent and augmented corrector. J returns (F_x,F_λ), x0 is a vector and the initial point satisfies F=0. Orient the first tangent with positive first component and preserve orientation afterward.
import numpy as np
def pseudo_arclength(F,J,x0,lam0,ds,n):
  pass
Shift+Enter to run
QuizWhat does each test detect?
In two dimensions, which indicator is compatible with Hopf and why is the determinant insufficient?
Key idea
Pseudo-arclength follows a regular curve through folds; multiple shooting and collocation turn constraints at different times into coupled systems whose accuracy and stability must be checked.