Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have solved the following maximisation problem analytically. I would like to graph the solution as well so I can see it, but I am not sure how to do this with Maple, i have just started using it.

Maximise x+y subject to: $$ \begin {eqnarray*} x + 2y &\le& 4, \\ x + 2y &\le& 4, \\ x - y &\le& 1, \end {eqnarray*} $$where $x,y\ge0$.

share|cite|improve this question
up vote 2 down vote accepted

You could try something like this,


sol := Optimization:-Maximize( x+y, {2*x+y<=4, x>=0, y>=0} );

optpt := [eval(x,sol[2]), eval(y,sol[2]), sol[1]];  # optimal [x,y,z]

common := style=patchnogrid, transparency=0.4:
xrng,yrng,zrng := x=0..10, y=0..10, z=-10..10:

display( pointplot3d( [optpt], symbol=solidsphere, symbolsize=30,
                      color=red ),
         plot3d( x+y, xrng, yrng, style=patch ),
         implicitplot3d( x=0, xrng, yrng, zrng, common ),
         implicitplot3d( 2*x+y-4, xrng, yrng, zrng, common ),
         axes=box, view=[0..4,0..5,0..10] );

Another way is to invoke the Optimization:-Interactive() command, which brings up a pop-up assistant. In that assistant, enter the constraints and objective, toggle it as maximize, hit the Solve button, then the Plot button, and then change the returned object to be the Plot, and then Quit it. That should produce a similar 3D plot.

This question probably belongs more on (with the Maple tag) than here, as it's more a Maple programming question than a math question. You can also ask questions on

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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