Step 1: Write a file brownfgh.m that computes the objective function, the gradient of the objective, and the sparse tridiagonal
Hessian matrix.

The file is lengthy so is not included here. View the code with
the command

type brownfgh

Because brownfgh computes the gradient and
Hessian values as well as the objective function, you need to use optimoptions to indicate that this information
is available in brownfgh, using the SpecifyObjectiveGradient and Hessian options.

The sparse matrix Aeq and vector beq are
available in the file browneq.mat:

load browneq

The linear constraint system is 100-by-1000, has unstructured
sparsity (use spy(Aeq) to
view the sparsity structure), and is not too badly ill-conditioned:

condest(Aeq*Aeq')
ans =
2.9310e+006

Step 2: Call a nonlinear minimization routine with a starting point xstart.

Local minimum possible.
fmincon stopped because the final change in function value relative to
its initial value is less than the default value of the function tolerance.

The exitflag value of 3 also
indicates that the algorithm terminated because the change in the
objective function value was less than the tolerance OptimalityTolerance.
The final function value is given by fval.