# Maximize, FindMaximum and Plot3D

I have mathematica 11.2 and I'm trying to find the maximum of this function: 3*(1 - 1/3 - y)*3*(-x - 1/3)*(x + y) where -1<x<1, -1<y<1 and xy>0. If I use Maximize I get this warning:

"Warning: there is no maximum in the region in which the objectivefunction is defined and the constraints are satisfied; a result on the boundary will be returned"

and I get {8, {x -> 1, y -> 1}}. I get the same values if I use NMaximize, however if I use FindMaximum I get: {0.0123457, {mf -> -0.444444, tf -> 0.555556}} which looks more reasonable.

However if I try to plot the function using Plot3D[3/1*(1 - 1/3 - y)*3/1*(-x - 1/3)*(x + y), {x, -1, 1}, {y, -1, 1}, AxesLabel -> Automatic, PlotRange -> {{-1, 1}, {-1, 1}, {0, 10}}, MaxRecursion -> 15] I get something very strange. Why is that?

• I get exactly the same result from Maximize and FindMaximum but perhaps you are using those in a slightly different way from what I am guessing. If you include exactly the code that you are using then perhaps others can exactly reproduce your puzzling results. (Imagine the reader knows NOTHING more than what you have written about what you have done) For your "very strange" plot, your z plot range of {0,10} is cutting off everything below z==0 and I am guessing that is what you are confused by. If you change your z plot range to {-5,10} then you should get a less very strange plot. – Bill Apr 6 '18 at 16:46
• Maximize[3*(1 - 1/3 - x)*3*(-x - 1/3)*(x + y), {x, y}] and FindMaximum[{3/1*(1 - 1/3 - y)*3/1*(-x - 1/3)*(x + y)}, {x, y}] is what I used. Maximize says Indeterminate, FindMaximum gives me 2.121756166887642*10^314 – Rby Apr 6 '18 at 17:17
• Why don't you immediately simplify your equation and reduce useless terms? You have two factors of $3$, you have terms like $1 - 1/3$, and so on. At the very least it makes your problem easier to understand. – David G. Stork Apr 6 '18 at 17:36
• Maximize[{3*(1-1/3-x)*3*(-x-1/3)*(x+y),-1<x<1&&-1<y<1&&x*y>0 },{x,y}] and FindMaximum[{3/1*(1-1/3-y)*3/1*(-x-1/3)*(x+y),-1<x<1&&-1<y<1&&x*y>0},{x,y}] enforce your constraints and return exactly the same result, well except for the second one including decimals for an approximate result – Bill Apr 6 '18 at 17:44
• Plotting the function with Plot3D[3*(1 - 1/3 - y)*3*(-x - 1/3)*(x + y), {x, -1, 1}, {y, -1, 1}, PlotRange -> All] clearly shows the maximum occurs at {1,1}, but the surface is still rising which is what your message means by giving you a value on your boundary. – Bill Watts Apr 7 '18 at 0:42