2
$\begingroup$

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?

$\endgroup$

1 Answer 1

4
$\begingroup$

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]

$\endgroup$
2
  • $\begingroup$ 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]. $\endgroup$
    – bahram
    Nov 14, 2019 at 20:52
  • $\begingroup$ @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. $\endgroup$
    – Bill
    Nov 15, 2019 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.