Message Boards Message Boards

0
|
2727 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to solve inequalities ?

Posted 9 years ago

Hi everyone,

I'm a new user of Wolfram and I want to know how to solve some inequalities. I spend a lot of time for an easy problem but I don't know how to write it in terms of wolfram language. So, I need your help. Here's my problem :

z=100x+200y to find z i have to find x & y

But,

4x+2y<=440

x+4y<=480

x+y<=150

x<=90 and of course x,y>=0

How should I write it to solve my problem ?

Thanks you.

2 Replies

Well, you could look for the interval for which all the conditions on x and y are fulfilled. This can be done like so:

Reduce[4 x + 2 y <= 440 && x + 4 y <= 480 && x + y <= 150 && x <= 90 &&x >= 0 && y >= 0, {x, y}]

You get

(0 <= x <= 40 && 0 <= y <= (480 - x)/4) || (40 < x <= 70 && 0 <= y <= 150 - x) || (70 < x <= 90 && 0 <= y <= 220 - 2 x)

You can get z

Solve[z == 100 x + 200 y  && (Reduce[4 x + 2 y <= 440 && x + 4 y <= 480 && x + y <= 150 && x <= 90 && x >= 0 && y >= 0, {x, y}]), z, Reals]

which gives:

{{z -> ConditionalExpression[100 x + 200 y, (0 < x < 90 && 0 < y < 40) || (x > 0 && 40 < y < 80 && -220 + 2 x + y < 0) || (x > 0 && 80 < y < 110 &&x + y < 150) || (x > 0 && 110 < y < 120 && x + 4 y < 480)]}}

If you want to maximize z you might want to look into expressions like:

Maximize[100 x + 200 y , (Reduce[4 x + 2 y <= 440 && x + 4 y <= 480 && x + y <= 150 && x <= 90 && x >= 0 && y >= 0, {x, y}]), {x, y}]

which finds:

{26000, {x -> 40, y -> 110}}

If you feel like it, you can also plot the whole thing:

Show[Plot3D[100 x + 200 y, {x, 0, 200}, {y, 0, 200}, 
  RegionFunction -> 
   Function[{x, y, z}, 
    Evaluate[
     Reduce[4 x + 2 y <= 440 && x + 4 y <= 480 && x + y <= 150 && 
        x <= 90 && x >= 0 && y >= 0, {x, y}][[1]]]]], 
 Plot3D[100 x + 200 y, {x, 0, 200}, {y, 0, 200}, 
  RegionFunction -> 
   Function[{x, y, z}, 
    Evaluate[
     Reduce[4 x + 2 y <= 440 && x + 4 y <= 480 && x + y <= 150 && 
        x <= 90 && x >= 0 && y >= 0, {x, y}][[2]]]]], 
 Plot3D[100 x + 200 y, {x, 0, 200}, {y, 0, 200}, 
  RegionFunction -> 
   Function[{x, y, z}, 
    Evaluate[
     Reduce[4 x + 2 y <= 440 && x + 4 y <= 480 && x + y <= 150 && 
        x <= 90 && x >= 0 && y >= 0, {x, y}][[3]]]]]]

enter image description here

If you minimize the expression:

Minimize[100 x + 200 y , (Reduce[4 x + 2 y <= 440 && x + 4 y <= 480 && x + y <= 150 && x <= 90 && x >= 0 && y >= 0, {x, y}]), {x, y}]

you find

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

so it appears that z can take values between 0 and 26000.

Cheers,

Marco

POSTED BY: Marco Thiel

Oh great, thanks you. Wolfram advised me to reduce it but i didn't know how to do it.

Need to spend some time on this new program.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract