# Summarizing Ternary Search

The triple search is the method of finding the minimum (maximum) of a function of one variable. How is it more convenient to apply to the function of 2 variables?

• just handle two variables at once in parallel. Or alternately. In this case, the search area will not be a segment, but a "rectangle". Of course, this will not work for all functions, but only if the expected minimum / maximum lies within the specified limits and there is no "saddle". - KoVadim
• so it is possible? Let there be f (x, y) - mat. function of 2 variables. searchV (valX, L, R, EPS) is a function that searches for the maximum value of the function f (x, y) by y, substituting the value valX for x. search (L, R, EPS) {- the function returns the maximum value of the function f (x, y) searchV (valX, L, R, EPS) {... while (LR <EPS) {..... a = ( 2L + R) / 3; ..... b = (L + 2R) / 3; ..... if (f (valX, a)> f (valX, b)) {....... r = b; .....} else {....... l = a; .....} ...} return f (valX, a); } - mazzachuses
• In fact, the search for the extremum of a function of several variables is a very difficult subject of computational mathematics. - alexlz