# Function of Maximum and Minimum Functions of Two Functions

I try to answer this question The Maximum and Minimum Functions of Two Functions

I wrote the following code

f[x_, y_] := 1 + 2*x + 3*y^3
g[x_, y_] := y + x^2
maxi[x_, y_] :=
Refine[{(f[x, y] + g[x, y])/2 + Abs[f[x, y] - g[x, y]]/2},
Assumptions -> {0 <= x <= 1, 0 <= y <= 1}]
Plot3D[maxi[x, y], {x, 0, 1}, {y, 0, 1}]


Is there any way to find function of maxi?

Try

Simplify[(f[x, y] + g[x, y])/2 + Abs[f[x, y] - g[x, y]]/2,0<=x<=1&&0<=y<=1]


which instantly returns

1+2 x+3 y^3


You can see that by inspection because f[x,y]>g[x,y] over the domain so the Abs does nothing and disappears and that leaves f[x,y]/2+g[x,y]/2+f/x,y]/2-g[x,y]/2==f[x,y]

• Many thanks. But your answer does not work for: f[x_] := x^2 and g[x_] := 1 - x, maxi1[x_] = Refine[{(f[x] + g[x])/2 + Abs[f[x] - g[x]]/2}, Assumptions -> {0 <= x <= 1}]; and Simplify[maxi1[x], 0 <= x <= 1]. Nov 14 '19 at 20:52
• @bahram If you change the question then the answer usually changes. Try this for your new f and g: f[x_] := x^2; g[x_] := 1 - x; list={{f[x],Reduce[f[x]>=g[x]&&0<=x<=1,x]}, {g[x],Reduce[f[x]<=g[x]&&0<=x<=1,x]}}; Piecewise[list] which gives you a Piecewise function that is the maximum of f and g over the domain. The minimum can be obtained in the same way. But I suspect this answer will not be satisfactory for you either.
– Bill
Nov 15 '19 at 7:11