-3
$\begingroup$

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

enter image description here

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

enter image description here

$\endgroup$
4
  • 2
    $\begingroup$ Post code not screenshots. Copy and paste from your notebook into a block ``` ``` $\endgroup$
    – flinty
    Oct 28 '21 at 21:32
  • 1
    $\begingroup$ 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. $\endgroup$
    – flinty
    Oct 28 '21 at 21:36
  • $\begingroup$ @flinty thank you! NMazimize worked! Sorry for screenshots, I wanted to be clearer and more concise. $\endgroup$
    – Tech
    Oct 28 '21 at 21:52
  • $\begingroup$ When you use inexact input, such as y <= 0.999, Maximize calls NMaximize. Maximize seems unable to solve the equations that yield the maximum. $\endgroup$
    – Michael E2
    Oct 29 '21 at 1:14
2
$\begingroup$
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]

enter image description here

$\endgroup$

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