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

  1. function [stepmin]=cubici2(graddold,matl,matx)
  2. %CUBICI2 Cubicly interpolates 3 points and 1 gradient.
  3. %
  4. %    This function uses cubic interpolation and
  5. %     the values of 3  points and one gradient.
  6.  
  7. %    Copyright (c) 1990 by the MathWorks, Inc.
  8. %    Andy Grace 7-9-90.
  9. abd=[1/3*matx.^3, 0.5*matx.^2, ones(3,1)]\(matl-graddold*matx);
  10. root=real(sqrt(abd(2)^2-4*abd(1)*graddold));
  11. x1=(-abd(2)+root)/(2*abd(1));
  12. if 2*abd(1)*x1+abd(2)>0
  13.     stepmin=x1;
  14.    else
  15.     stepmin=(-abd(2)-root)/(2*abd(1));
  16. end
  17. if stepmin<0|isnan(stepmin)|stepmin==Inf , stepmin=abs(quadi(matx,matl));end
  18. if isnan(stepmin),stepmin=matx(2)/2; end
  19.  
  20. % fbest=1/3*abd(1)*stepmin^3+0.5*abd(2)*stepmin^2+graddold*stepmin+matl(1);
  21.