# Maximize a function containing Max

I am trying to maximize a function (involving several Max and Min) in two variables and one parameter with some constraints. After struggling with it, I am trying with smaller examples to understand what I am doing wrong. I write here the three small examples I am working on:

1) 2 variables and 1 parameter:

    Maximize[100 g x - 1/6 y + x, 0 < y < 10 && 0 < x < 10 && g > 0, {x, y}]


which gives the solution:

    10 (1 + 100 g), g>0
-\[Infinity], True


{x -> Indeterminate, y -> Indeterminate}}

2) 2 variables and a Max:

    Maximize[100  x - 1/6 y + Max[0, x], 0 < y < 10 && 0 < x < 10 , {x, y}]


which gives the solution:

   1010, {x -> 10, y -> 0}


3) 2 variables, 1 parameter and a Max:

   Maximize[100 g x - 1/6 y + Max[0, x], g > 0 && 0 < y < 10 && 0 < x < 10 , {x,y}]


which does not solve the problem; just gives this solution:

    Maximize[100 g x - 1/6 y + Max[0, x], g > 0 && 0 < y < 10 && 0 < x < 10 ,{x,y}].


Now my question is: why the combination of case 1) and 2) together does not work?

Thank you very much!

• I don't understand. If you assume x>0, then Max[x, 0]=x. Why you need Max function? Apr 4, 2018 at 2:23

Make the intervals half-closed (or closed)

Assuming[g > 0,
Maximize[{100 g x - 1/6 y + x, 0 <= y < 10, 0 < x <= 10}, {x, y}] //
Simplify]

(* {10 + 1000 g, {x -> 10, y -> 0}} *)


EDIT:

Assuming[{g > 0, x > 0},
Maximize[{100 g x - 1/6 y + Max[x, 0], 0 <= y <= 10,
0 < x <= 10}, {x, y}] // Simplify]

(* {10 + 1000 g, {x -> 10, y -> 0}} *)

• Hi, thank you for your answer. However, this suggestion still does not work when I have to maximize a function containing a Max, e.g.: Assuming[g > 0, Maximize[{100 g x - 1/6 y + Max[x, 0], 0 <= y <= 10, 0 < x <= 10}, {x, y}] // Simplify], which cannot be solved..
– Mary
Apr 3, 2018 at 7:27
• The OP contains both the constraints and the use of Max. I agree that the Max is redundant. Reiterating part of the constraint is necessary to help the Simplify deal with the Piecewise. Apr 4, 2018 at 2:35