Open e04uc_demo.m in the Editor
Run demo

NAG routine e04uc is designed to find a minimum point of an arbitrary smooth function, which may be subject to linear and nonlinear constraints, using a sequential quadratic programming (SQP) method - see the e04uc document for more details of the method.

You can use this demo to illustrate finding a minimum of one of two functions with e04uc. The first one is the well-known Rosenbrock function, which is a 2D function given by

f(x,y) = 100(y-x2)2 + (1-x)2

The second function handled by this demo is MATLAB's "peaks" function, which can be computed using the MATLAB call

  [x,y,z] = peaks;


Figure 1 - using e04uc to minimize Rosenbrock's function

Demo controls

The demo can be controlled by use of a number of buttons and drop-down list boxes, down the left-hand side and along the bottom of the GUI.

Because of the 'banana shaped valley' contours characteristic of Rosenbrock's function, as shown in figure 1 above, the function is often used as a test problem for minimization routines like e04uc. Simplistic algorithms such as a basic 'steepest descent' method have a hard time following the shallow curving valley floor in their quest for the minimum point, but the NAG routine has no trouble.

Derivative information

A feature of e04uc is that the first derivatives of the function to be minimized are not required to be known analytically. If they are not known, or are hard to determine, e04uc can estimate them using difference approximations. If the user is able to supply them, though, convergence of the algorithm is likely to be faster and more robust.


Figure 2 - the demo set up to minimize the peaks function, with some linear constraints

When the problem has been solved, you can use the "Repeat problem" button to solve the same problem again, perhaps after choosing a different starting point.