QuadCost:

--------------------------------------------------------------------------
   Finds the alpha that minimizes the quadratic cost functional J
   where

   x         = x0 + alpha*d;
   J         = (1/2) (rho'*W*rho + 0.5*(x-xA)'*S0*(x-xA))
   dJ/dalpha = d'*(S0*(x-xA) - H'*W*rho);
   rho       = z - h
   h/x     = H

   Calls a function fx defined by
   [rho,H,W,JL] = fx(x);

   rho       = y - h
   H         = h/x
   W         = Residual weighting vector
   JL        = is a cost adjustment scalar

--------------------------------------------------------------------------
   Form:
   [J, dJ] = QuadCost( fx, x0, xA, d, S0, amin, amax )
--------------------------------------------------------------------------

   ------
   Inputs
   ------
   fx                     The name of the function
   x0                     Current value of x
   xA                     Reference value of x (for S0)
   d                      Alpha*d is the next increment to x
   S0                     A priori state covariance matrix
   xA                     A priori state
   amin                   Minimum alpha
   amax                   Maximum alpha

   -------
   Outputs
   -------
   J                      Cost
   dJ                     Derivative of the cost

--------------------------------------------------------------------------

Children:

Common: Graphics/NewFig