# Defining a function to be the minimum of two other functions

I cannot find a way to define a function as the minimum of two other functions that each have the same two independent variables. I have f(x,y) and g(x,y), and I would like to find $h = \min\{f(x,y),g(x,y)\}$. $h$ is not a numerical answer, but a piecewise function; i.e., $h = f(x,y)$ for $f(x,y)<g(x,y)$, and $h=g(x,y)$ for $f(x,y)>=g(x,y)$.

Additionally, I would like to find the function that maximizes $h$ with respect to the variable $y$ and plot it in the xy-plane.

• Sounds like homework. – Alan May 1 '18 at 0:18
• What have you tried? Have you looked at Min in the documentation? – eyorble May 1 '18 at 0:22
• I am doing an analysis on a baseball bunting play where x is the distance the fielder is from the plate and y is the angle the ball is hit at. G and F represents the likelihood of an out given that a specific player fields the ball. Thus it is natural that the minimum of these functions would indicate who should field the ball. While the hitter maximizes this likelihood of a hit fcn, h, by choosing the angle y. – Alexander Pingry May 1 '18 at 1:10
• Under Min in documentation it is not used as function, rather an operation. – Alexander Pingry May 1 '18 at 1:11

Since you haven't said what f and g are, I've just picked something at random:

f[x_, y_] := x y;
g[x_, y_] := x^2 + y^2;
h[x_, y_] := Min[f[x, y], g[x, y]]


If you prefer, you can explicitly make h a piecewise function:

h2[x_, y_] := Piecewise[{{f[x, y], f[x, y] <= g[x, y]},
{g[x, y], f[x, y] > g[x, y]}}]

• For fun: h3 = Through@*Min[f, g]. – AccidentalFourierTransform May 1 '18 at 3:28
• h[x_, y_] = Min[f[x, y], g[x, y]] // PiecewiseExpand – Bob Hanlon May 1 '18 at 5:37