# FindMaximum starts with a point outside the range

I try to find a maximum of a function using:

FindMaximum[{Log[81 x + 19] + Log[80 y + 20] + Log[60 (1 - x - y) + 40],
0 < x < 1, 0 < y < 1, x + y < 1}, {x, y}]


I get an error message:

FindMaximum::nrnum: The function value -11.1219-3.14159 I is not a real number at {x,y} = {0.9,0.9}.


Sure, it is not a real number since $60(1-x-y)-40<0$. But why did FindMaximum even tried these values? They are outside the range $x+y<1$!

Is there a way to tell FindMaximum to only look inside the range?

• As an alternative, NMaximize works with your system with no errors. Additionally, if you provide a better starting point than the one selected automatically, FindMaximum works as well: FindMaximum[{Log[81 x + 19] + Log[80 y + 20] + Log[60 (1 - x - y) + 40], 0 < x < 1, 0 < y < 1, x + y < 1}, {{x, 0.5}, {y, 0.4}}] returns {11.8731, {x -> 0.48251, y -> 0.467078}}. – MarcoB May 4 '18 at 8:35
• @MarcoB yes, NMaximize works, but since my goal functions are convex, I think that FindMaximum should work faster. I also tried to change the initial values and it worked, but I do not understand why Mathematica tries values outside the range at all? – Erel Segal-Halevi May 4 '18 at 8:43
• I don't know why MMA can't find a starting value, but you could provide a starting value. FindMaximum[{Log[81 x + 19] + Log[80 y + 20] + Log[60 (1 - x - y) + 40], 0 <= x <= 1, 0 <= y <= 1, x + y <= 1}, {{x, 0}, {y, 0} } ] evaluates the result without error message. – Ulrich Neumann May 4 '18 at 9:19
• Maybe choosing the starting point for numerical optimization algorithms is too vital to leave it to a dull machine? ;) – Henrik Schumacher May 4 '18 at 9:32