Post Reply 
Find minimum or maximum of multi-variable function
08-16-2021, 07:47 PM (This post was last modified: 08-16-2021 07:48 PM by jte.)
Post: #16
RE: Find minimum or maximum of multi-variable function
(08-16-2021 08:57 AM)rawi Wrote:  
Quote:I’m not sure whether there is a function or command which can find the minimum or maximum of multi-variable function e.g

find min of Sqrt((x-14)^2 + (y-55)^2) + Sqrt((x-23)^2 + (y-95)^2)

Or any application which can help finding this kind of problem?

I have written a program called NMO for optimization for multivariate functions using Nelder-Mead-Method (a variant of the Simplex Method) that can be found her: https://www.hpmuseum.org/forum/thread-16426.html

I just tried it out! Smile I did notice what seems to be a slight typo: “Parmater” (instead of “Parameter”, I’m assuming…).

Quote:You have to put in a function FUNCX() with L1(1) as x and L1(2) as y which in your case looks like this (> stands for STO |> ):

EXPORT FUNCX()
BEGIN
LOCAL Q1;
SQRT((L1(1)-14)^2+(L1(2)-55)^2)+SQRT((L1(1)-23)+(L1(2)-95)^2) > Q1
RETURN Q1;
END;

Then you have to put starting values in L1, e.g. {14,55} > L1

Then call NMO

Put in 0.5 for S0 (ininitial step width) and 0.0001 for E0 (termination criterion) and 500 for ITM (maximum number of iterations) and press OK.

Within seconds the procedure stops at Minimum 41.000000. At list L1 you see the minimum value is exactly your starting point 14 and 55.
The same is the case if you start with x=23 and y=95. We get the same minimum 41.00000 for x=23 and y=95

If we start with {0,0} we get exactly the same function value 41.000000 with x = 15.7478 and y = 62,7679.

I got the same results once I got all four squaring operations into my local FUNCX. Smile

Code:
{23,95}▶L1; NMO(0.5,0.0001,500); L1
{23,95}

{14,55}▶L1; NMO(0.5,0.0001,500); L1
{14,55}

{0,0}▶L1; NMO(0.5,0.0001,500); L1
{15.7478084758,62.767948195}

(With an Fmin of 41 reported in each case.) Of course, I had to play around and try some other values! Big Grin

Quote:So your problem seems to have multiple minima.

Yes; the Advanced Graphing plot above (of a line segment) shows where the minima are.

(To be more precise: the plot contains the intersection of the zero sets of the two partial derivatives. This intersection, in turn, contains the extrema [minima, maxima, and saddle points], excepting perhaps the endpoints of the segment [as there are divisions by zero there; some additional care is warranted there], as the partial derivatives exist. Second [partial] derivative tests can further clarify the situation, and could be plotted… or a little thought can be put in whilst looking at the original function. [To rule out the other types of extrema or to recognize it is the sum of distances between two points.])
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Find minimum or maximum of multi-variable function - jte - 08-16-2021 07:47 PM



User(s) browsing this thread: 3 Guest(s)