MHB Extrapolation and interpolation in line search optimization

AI Thread Summary
The equations discussed relate to cubic and quadratic interpolation used in line search optimization within MATLAB's fmincg function. The user seeks the origin of these specific equations, noting they are not found in standard numerical optimization literature, including a referenced book by Peter Glynn and Stephen M. Robinson. It is suggested that these equations may originate from Andrew Ng's Coursera Machine Learning course. The code implements a conditional check to determine whether to use a quadratic or cubic fit based on the function values. Ultimately, the recommendation is to focus on the code's functionality rather than its theoretical origins, while acknowledging the potential for errors in the implementation.
mathu2057
Messages
1
Reaction score
0
hi
can you tell me these equations:

A = 6*(f2-f3)/z3+3*(d2+d3); % cubic fit
B = 3*(f3-f2)-z3*(d3+2*d2);
z2 = (sqrt(B*B-A*d2*z3*z3)-B)/A; % numerical error
in MATLAB fmincg.m
https://github.com/emersonmoretto/mlclass-ex3/blob/master/fmincg.m
come from where??
it is either cubic interpolation or cubic interpolation...i look for
these equation in many website and books numerical optimization but
i do not find these equation even the book numerical optimization
for Peter Glynn Stephen M. Robinson p:57.(in the attachment copy of the page).it is not same in matlab
please help me from where these equation come from?
 

Attachments

  • eqq.jpg
    eqq.jpg
    53.7 KB · Views: 136
Mathematics news on Phys.org
From the MATLAB site I found some mention that they came from Coursera Machine Learning course taught by Andrew Ng.

https://www.mathworks.com/matlabcen...rization-used-to-classify-hand-written-digits

https://scicomp.stackexchange.com/questions/25876/understanding-matlabs-fmincg-optimization-function

In the code there is a test f2>f1 if true then a quadratic fit is done and if false then a cubit fit is done.

Matlab:
  if f2 > f1
    z2 = z3 - (0.5*d3*z3*z3)/(d3*z3+f2-f3);                 % quadratic fit
  else
    A = 6*(f2-f3)/z3+3*(d2+d3);                                 % cubic fit
    B = 3*(f3-f2)-z3*(d3+2*d2);
    z2 = (sqrt(B*B-A*d2*z3*z3)-B)/A;       % numerical error possible - ok!
  end

so I think you will just have to go with the code and not worry about where it comes from. The code should be sufficient for you to decide why they are needed. Of course, there is always the distinct possibility that the code is wrong but again you will have to test and decide if that's the case.
 
Seemingly by some mathematical coincidence, a hexagon of sides 2,2,7,7, 11, and 11 can be inscribed in a circle of radius 7. The other day I saw a math problem on line, which they said came from a Polish Olympiad, where you compute the length x of the 3rd side which is the same as the radius, so that the sides of length 2,x, and 11 are inscribed on the arc of a semi-circle. The law of cosines applied twice gives the answer for x of exactly 7, but the arithmetic is so complex that the...

Similar threads

Back
Top