# Maximize function problem [closed]

I don't understand why I'm getting no solution with the Maximize function in this case:

while it returns the right result when I impose $$y\leq0.999$$ (or, equivalently, $$x\leq0.999$$):

• Post code not screenshots. Copy and paste from your notebook into a block   Oct 28 '21 at 21:32
• I get a result in Mathematica 12.3.1 see here imgur.com/a/bBp2wl7 however it's very complex and contains many Root objects. Using N to make this numerical gives {1.58496, {x -> 0.333333, y -> 0.333333}} which matches yours. Try with NMaximize instead if you just need a numerical result. Oct 28 '21 at 21:36
• @flinty thank you! NMazimize worked! Sorry for screenshots, I wanted to be clearer and more concise.
– Tech
Oct 28 '21 at 21:52
• When you use inexact input, such as y <= 0.999, Maximize calls NMaximize. Maximize seems unable to solve the equations that yield the maximum. Oct 29 '21 at 1:14

Clear["Global*"]

f = -x*Log[2, x] - y*Log[2, y] -
(1 - x - y)*Log[2, 1 - x - y];


To find simple forms of the exact solution, set the derivatives equal to zero. The maximum is located at

{arg} = Solve[{D[f, x] == 0, D[f, y] == 0,
0 <= x <= 1, 0 <= y <= 1}, {x, y}]

(* {{x -> 1/3, y -> 1/3}} )


The maximum is

max = f /. arg

(* Log[3]/Log[2] *)

max // N

(* 1.58496 *)

Show[
Plot3D[f, {x, 0, 1}, {y, 0, 1},
PlotStyle -> Opacity[0.8]],
Graphics3D[{Red, AbsolutePointSize[6],
Point[{1/3, 1/3, Log[3]/Log[2]}]}],
PlotRange -> All]
`