MATHEMATICA TUTORIAL

"OrthogonalProjection" Method for NDSolve

Introduction

Consider the matrix differential equation

where the initial value is given. Assume that , that the solution has the property of preserving orthonormality, , and that it has full rank for all .

From a numerical perspective, a key issue is how to numerically integrate an orthogonal matrix differential system in such a way that the numerical solution remains orthogonal. There are several strategies that are possible. One approach, suggested in [DRV94], is to use an implicit Runge-Kutta method (such as the Gauss scheme). Some alternative strategies are described in [DV99] and [DL01].

The approach taken here is to use any reasonable numerical integration method and then postprocess using a projective procedure at the end of each integration step.

An important feature of this implementation is that the basic integration method can be any built-in numerical method, or even a user-defined procedure. In the following examples an explicit Runge-Kutta method is used for the basic time stepping. However, if greater accuracy is required an extrapolation method could easily be used, for example, by simply setting the appropriate Method option.

Projection Step

At the end of each numerical integration step you need to transform the approximate solution matrix of the differential system to obtain an orthogonal matrix. This can be carried out in several ways (see for example [DRV94] and [H97]):

  • Newton or Schulz iteration
  • QR decomposition
    • Singular value decomposition

    The Newton and Schulz methods are quadratically convergent, and the number of iterations may vary depending on the error tolerances used in the numerical integration. One or two iterations are usually sufficient for convergence to the orthonormal polar factor (see the following) in IEEE double-precision arithmetic.

    QR decomposition is cheaper than singular value decomposition (roughly by a factor of two), but it does not give the closest possible projection.

    Definition (Thin singular value decomposition [GVL96]): Given a matrix with there exist two matrices and such that is the diagonal matrix of singular values of , , where . has orthonormal columns and is orthogonal.

    Definition (Polar decomposition): Given a matrix and its singular value decomposition , the polar decomposition of is given by the product of two matrices and where and . has orthonormal columns and is symmetric positive semidefinite.

    The orthonormal polar factor of is the matrix that solves

    for the 2 and Frobenius norms [H96].

Schulz Iteration

The approach chosen is based on the Schulz iteration, which works directly for . In contrast, Newton iteration for needs to be preceded by QR decomposition.

Comparison with direct computation based on the singular value decomposition is also given.

The Schulz iteration is given by

The Schulz iteration has an arithmetic operation count per iteration of floating-point operations, but is rich in matrix multiplication [H97].

In a practical implementation, GEMM-based level 3 BLAS of LAPACK [LAPACK99] can be used in conjunction with architecture-specific optimizations via the Automatically Tuned Linear Algebra Software [ATLAS00]. Such considerations mean that the arithmetic operation count of the Schulz iteration is not necessarily an accurate reflection of the observed computational cost. A useful bound on the departure from orthonormality of is in [H89]: . Comparison with the Schulz iteration gives the stopping criterion for some tolerance .

Standard Formulation

Assume that an initial value for the current solution of the ODE is given, together with a solution from a one-step numerical integration method. Assume that an absolute tolerance for controlling the Schulz iteration is also prescribed.

The following algorithm can be used for implementation.

Step 1. Set and .

Step 2. Compute .

Step 3. Compute .

Step 4. If or then return .

Step 5. Set and go to step 2.

Increment Formulation

NDSolve uses compensated summation to reduce the effect of rounding errors made by repeatedly adding the contribution of small quantities to at each integration step [H96]. Therefore, the increment is returned by the base integrator.

An appropriate orthogonal correction for the projective iteration can be determined using the following algorithm.

Step 1. Set and .

Step 2. Set .

Step 3. Compute .

Step 4. Compute .

Step 5. If or , then return .

Step 6. Set and go to step 2.

This modified algorithm is used in and shows an advantage of using an iterative process over a direct process, since it is not obvious how an orthogonal correction can be derived for direct methods.

Examples

Orthogonal Error Measurement

A function to compute the Frobenius norm of a matrix can be defined in terms of the Norm function as follows.
In[1]:=
Click for copyable input
An upper bound on the departure from orthonormality of can then be measured using this function [H97].
In[2]:=
Click for copyable input
This defines the utility function for visualizing the orthogonal error during a numerical integration.
In[4]:=
Click for copyable input
In[6]:=
Click for copyable input

Square Systems

This example concerns the solution of a matrix differential system on the orthogonal group (see [Z98]).

The matrix differential system is given by

with

and

The solution evolves as

The eigenvalues of are , , . Thus as approaches , two of the eigenvalues of approach -1. The numerical integration is carried out on the interval .
In[7]:=
Click for copyable input
In[8]:=
Click for copyable input
This computes the solution using an explicit Runge-Kutta method. The appropriate initial step size and method order are selected automatically, and the step size may vary throughout the integration interval, which is chosen in order to satisfy local relative and absolute error tolerances. Alternatively, the order of the method could be specified by using a Method option.
In[16]:=
Click for copyable input
This computes the orthogonal error, or absolute deviation from the orthogonal manifold, as the integration progresses. The error is of the order of the local accuracy of the numerical method.
In[17]:=
Click for copyable input
Out[18]=
This computes the solution using an orthogonal projection method with an explicit Runge-Kutta method used for the basic integration step. The initial step size and method order are the same as earlier, but the step size sequence in the integration may differ.
In[19]:=
Click for copyable input
Using the orthogonal projection method, the orthogonal error is reduced to approximately the level of roundoff in IEEE double-precision arithmetic.
In[20]:=
Click for copyable input
Out[21]=
The Schulz iteration, using the incremental formulation, generally yields smaller errors than the direct singular value decomposition.

Rectangular Systems

In the following example it is shown how the implementation of the orthogonal projection method also works for rectangular matrix differential systems. Formally stated, the interest is in solving ordinary differential equations on the Stiefel manifold, the set of × orthogonal matrices with .

Definition The Stiefel manifold of × orthogonal matrices is the set , , where is the × identity matrix.

Solutions that evolve on the Stiefel manifold find numerous applications such as eigenvalue problems in numerical linear algebra, computation of Lyapunov exponents for dynamical systems and signal processing.

Consider an example adapted from [DL01]:

where , , with and .

The exact solution is given by

Normalizing as

it follows that satisfies the following weak skew-symmetric system on :

In the following example, the system is solved on the interval with and dimension .
In[22]:=
Click for copyable input
This computes the exact solution which can be evaluated throughout the integration interval.
In[36]:=
Click for copyable input
This computes the solution using an explicit Runge-Kutta method.
In[37]:=
Click for copyable input
This computes the componentwise absolute global error at the end of the integration interval.
In[39]:=
Click for copyable input
Out[39]=
This computes the orthogonal error—a measure of the deviation from the Stiefel manifold.
In[40]:=
Click for copyable input
Out[40]=
This computes the solution using an orthogonal projection method with an explicit Runge-Kutta method as the basic numerical integration scheme.
In[41]:=
Click for copyable input
The componentwise absolute global error at the end of the integration interval is roughly the same as before since the absolute and relative tolerances used in the numerical integration are the same.
In[43]:=
Click for copyable input
Out[43]=
Using the orthogonal projection method, however, the deviation from the Stiefel manifold is reduced to the level of roundoff.
In[44]:=
Click for copyable input
Out[44]=

Implementation

The implementation of the method has three basic components:

  • Initialization. Set up the base method to use in the integration, determining any method coefficients and setting up any workspaces that should be used. This is done once, before any actual integration is carried out, and the resulting object is validated so that it does not need to be checked at each integration step. At this stage the system dimensions and initial conditions are checked for consistency.
  • Invoke the base numerical integration method at each step.
    • Perform an orthogonal projection. This performs various tests such as checking that the basic integration proceeded correctly and that the Schulz iteration converges.

    Options can be used to modify the stopping criteria for the Schulz iteration. One option provided by the code is which allows control over the tolerance of the iteration. The factor is combined with a Unit in the Last Place, determined according to the working precision used in the integration ( for IEEE double precision).

    The Frobenius norm used for the stopping criterion can be computed efficiently using the LAPACK LANGE functions [LAPACK99].

    The option MaxIterations controls the maximum number of iterations that should be carried out.

Option Summary

option name
default value
Dimensions{}specify the dimensions of the matrix differential system
"IterationSafetyFactor"specify the safety factor to use in the termination criterion for the Schulz iteration (1)
MaxIterationsAutomaticspecify the maximum number of iterations to use in the Schulz iteration (2)
Method"StiffnessSwitching"specify the method to use for the numerical integration

Options of the method .

New to Mathematica? Find your learning path »
Have a question? Ask support »