"Projection" Method for NDSolve


When a differential system has a certain structure, it is advantageous if a numerical integration method preserves the structure. In certain situations it is useful to solve differential equations in which solutions are constrained. Projection methods work by taking a time step with a numerical integration method and then projecting the approximate solution onto the manifold on which the true solution evolves.

NDSolve includes a differential algebraic solver which may be appropriate and is described in more detail within "Numerical Solution of Differential-Algebraic Equations".

Sometimes the form of the equations may not be reduced to the form required by a DAE solver. Furthermore so-called index reduction techniques can destroy certain structural properties, such as symplecticity, that the differential system may possess (see [HW96] and [HLW02]). An example that illustrates this can be found in the documentation for DAEs.

In such cases it is often possible to solve a differential system and then use a projective procedure to ensure that the constraints are conserved. This is the idea behind the method "Projection".

If the differential system is -reversible then a symmetric projection process can be advantageous (see [H00]). Symmetric projection is generally more costly than projection and has not yet been implemented in NDSolve.


Consider a differential equation

where may be a vector or a matrix.

Definition: A nonconstant function is called an invariant of (1) if for all .

This implies that every solution of (2) satisfies .

Synonymous with invariant, the terms first integral, conserved quantity, or constant of the motion are also common.


Given an -dimensional submanifold of with

Given a differential equation (3) then implies for all . This is a weaker assumption than invariance and is called a weak invariant (see [HLW02]).

Projection Algorithm

Let denote the solution from a one-step numerical integrator. Considering a constrained minimization problem leads to the following system (see [AP91], [HW96] and [HLW02]):

To save work is approximated as . Substituting the first relation into the second relation in (4) leads to the following simplified Newton scheme for :

with .

The first increment is of size so that (5) usually converges quickly.

The added expense of using a higher-order integration method can be offset by fewer Newton iterations in the projective step.

For the termination criterion in the method "Projection", the option "IterationSafetyFactor" is combined with one Unit in the Last Place in the working precision used by NDSolve.


Load some utility packages:

Linear Invariants

Define a stiff system modeling a chemical reaction:
This system has a linear invariant:
Linear invariants are generally conserved by numerical integrators (see [S86]), including the default NDSolve method, as can be observed in a plot of the error in the invariant:

Therefore in this example there is no need to use the method "Projection".

Certain numerical methods preserve quadratic invariants exactly (see for example [C87]). The implicit midpoint rule, or one-stage Gauss implicit RungeKutta method, is one such method.

Harmonic Oscillator

Define the harmonic oscillator:
The harmonic oscillator has the following invariant:
Solve the system using the method "ExplicitRungeKutta". The error in the invariant grows roughly linearly, which is typical behavior for a dissipative method applied to a Hamiltonian system:
This also solves the system using the method "ExplicitRungeKutta" but it projects the solution at the end of each step. A plot of the error in the invariant shows that it is conserved up to roundoff:
Since the system is Hamiltonian (the invariant is the Hamiltonian), a symplectic integrator performs well on this problem, giving a small bounded error:

Perturbed Kepler Problem

This loads a Hamiltonian system known as the perturbed Kepler problem, sets the integration interval and the step size to take, as well as defining the position variables in the Hamiltonian formalism:
The system has two invariants, which are defined as H and L:

An experiment now illustrates the importance of using all the available invariants in the projective process (see [HLW02]). Consider the solutions obtained using:

Lotka Volterra

An example of constraint projection for the LotkaVolterra system is given within "Numerical Methods for Solving the LotkaVolterra Equations".

Euler's Equations

An example of constraint projection for Euler's equations is given within "Rigid Body Solvers".

Option Summary

option name
default value
"Invariants"Nonespecify the invariants of the differential system
"IterationSafetyFactor"specify the safety factor to use in the iterative solution of the invariants
MaxIterationsAutomaticspecify the maximum number of iterations to use in the iterative solution of the invariants
Method"StiffnessSwitching"specify the method to use for integrating the differential system numerically

Options of the method "Projection".