# Finding maximum/minimum value of system of inequalites

How would I get the maximum values for x1 and x2 given that I have plotted the region governed by the following system of inequalities? Basically want to find the smallest bounding box around the plot's coordinates

(x1 == -120 && x2 == 240) || (-120 < x1 <= -12 && -2 x1 <= x2 <= 120 - x1) ||
(-12 < x1 <= 0 && (60 - x1)/3 <= x2 <= 120 - x1) ||
(0 < x1 <= 30 && 1/3 (60 - 2 x1) <= x2 <= (240 - x1)/2) ||
(30 < x1 <= 60 && 30 - x1 <= x2 <= (240 - x1)/2) ||
(60 < x1 < 90 && 30 - x1 <= x2 <= 120 - 2 x1) || (x1 == 90 && x2 == -60)


I tried using the maximize function and maxvalue but both did not seem to work? E.g.

MaxValue::objv: The objective function (System of inequalities here) contains a nonconstant expression Less independent of variables {x1,x2}. >>

Could someone please tell me what to do here?

Thanks

• Kadir, you are missing the function you want to maximize in the Command. Format should be Maximize[{function,constraints},{x1,x2}]. For example Maximize[{x1+x2,your_Constraints},{x1,x2}] Aug 3, 2014 at 13:42
• I was literally just doing Maximize[{system of inequalities}, {x1,x2}], I just want the max and min values of x1 and x2? Aug 3, 2014 at 13:57
• I can do it individually if i do Maximize[x1, {system of inequalities}, {x1,x2}] is there a way to print the max min for x1 and x2 rather than having to call the max function twice and the min function twice? Aug 3, 2014 at 14:02

First define the constraint equation, and define $X=\{x_1,x_2\}$:

const = (x1 == -120 &&
x2 == 240) || (-120 < x1 <= -12 && -2 x1 <= x2 <=
120 - x1) || (-12 < x1 <= 0 && (60 - x1)/3 <= x2 <=
120 - x1) || (0 < x1 <= 30 &&
1/3 (60 - 2 x1) <= x2 <= (240 - x1)/2) || (30 < x1 <= 60 &&
30 - x1 <= x2 <= (240 - x1)/2) || (60 < x1 < 90 &&
30 - x1 <= x2 <= 120 - 2 x1) || (x1 == 90 && x2 == -60);
X = {x1, x2};


The following then returns the maximum and minimum values of $x_1$ and $x_2$ over the region:

First[Maximize[{#, const}, X]] & /@ X
First[Minimize[{#, const}, X]] & /@ X


Output:

{90, 240}

{-120, -60}

Plotting confirms that the result actually creates a bounding rectangle:

Show[{Graphics[Rectangle[{-120, -60}, {90, 240}]],
RegionPlot[const, {x1, -160, 110}, {x2, -110, 260},
PlotPoints -> 80]}]