Optimization Toolbox    

Nonlinear Equations with Jacobian

Consider the problem of finding a solution to a system of nonlinear equations whose Jacobian is sparse. The dimension of the problem in this example is 1000. The goal is to find x such that F(x) = 0. Assuming n = 1000, the nonlinear equations are

To solve a large nonlinear system of equations, F(x) = 0, use the large-scale method available in fsolve.

Step 1: Write an M-file nlsf1.m that computes the objective function values and the Jacobian

Step 2: Call the solve routine for the system of equations

A starting point is given as well as the function name. The large-scale method is the default, so it is not necessary to specify this in the options argument. Output at each iteration is specified. Finally, so that fsolve will use the Jacobian information available in nlsf1.m, you need to turn the Jacobian parameter 'on' using optimset.

The commands display this output.

A linear system is (approximately) solved in each major iteration using the preconditioned conjugate gradient method. The default value for PrecondBandWidth is 0 in options, so a diagonal preconditioner is used. (PrecondBandWidth specifies the bandwidth of the preconditioning matrix. A bandwidth of 0 means there is only one diagonal in the matrix.)

From the first-order optimality values, fast linear convergence occurs. The number of conjugate gradient (CG) iterations required per major iteration is low, at most 5 for a problem of 1000 dimensions, implying the linear systems are not very difficult to solve in this case (though more work is required as convergence progresses).

It is possible to override the default choice of preconditioner (diagonal) by choosing a banded preconditioner through the use of the parameter PrecondBandWidth. If you want to use a tridiagonal preconditioner, i.e., a preconditioning matrix with three diagonals (or bandwidth of one), set PrecondBandWidth to the value 1.

In this case the output is

Note that although the same number of iterations takes place, the number of PCG iterations has dropped, so less work is being done per iteration. See Preconditioned Conjugate Gradients.


 Problems Covered by Large-Scale Methods Nonlinear Equations with Jacobian Sparsity Pattern