home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 4.ddi / OPTIM.DI$ / QUAD2.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  532 b   |  18 lines

  1. function [maximum,err]=quad2(pts,checkpt,location)
  2. %QUAD2    Quadraticly interpolates three points to find the maximum value.
  3. %    QUAD2(PTS,CHECKPT,LOCATION)
  4. %    The second argument, CHECKPT, is for estimation of the error 
  5. %    in the interpolated maximum. 
  6. c=pts(1);
  7. ab=[-1 0.5; 2 -0.5]*(pts(2:3)-c*ones(2,1));
  8. stepmin=-ab(2)/(2*ab(1));
  9. maximum=ab(1)*stepmin^2+ab(2)*stepmin+c;
  10. if nargin>1
  11.     if location==0
  12.         checkpt2=-abc(1)+abc(2)-abc(3)+d;
  13.     else
  14.         checkpt2=64*abc(1)+16*abc(2)+4*abc(3)+d;
  15.     end
  16.     err=checkpt-checkpt2;
  17. end
  18.