Finding the max of a function of three variables with Lagrange multipliers

33 Views Asked by At

I want to find the maximum value of the function $f$ and the variables that satisfy this value. $$f(x, y, z) = -\left(x + \frac{y}{2}\right) \log_2\left(x + \frac{y}{2}\right) - \left(z + \frac{y}{2}\right) \log_2\left(z + \frac{y}{2}\right) - y$$ $x$,$y$ and $z$ are probability variables, so there is $x+y+z=1$ condition.(And of course $0\leq x,y,z\leq 1$ )

Intuitively it is clear that the function is $1$ when $x=0.5$, $y=0$ and $z=0.5$ but I could not show it mathematically.

I used the Lagrange multipliers method but I didn't get the result.

$L(x,y,z,\lambda)=f(x, y, z)-\lambda(x+y+z-1)$
$\frac{df}{dx} =- \lambda - \frac{\log(x + \frac{y}{2})}{\log(2)} - \frac{1}{\log(2)}$

$\frac{df}{dy} =- \lambda - \frac{\log\left(x + \frac{y}{2}\right)}{2 \log(2)} - \frac{\log\left( z + \frac{y}{2} \right )}{2 \log(2)} - \frac{1}{\log(2)} - 1 $

$\frac{df}{dz} =- \lambda - \frac{\log(z + \frac{y}{2})}{\log(2)} - \frac{1}{\log(2)}$

In the function, base of log is 2 but in the derivative it is the natural log, just to avoid confusion.

1

There are 1 best solutions below

0
On

We can set $u=x+\frac y2$, so as to deal we a function of $2$ variables $u,y$

$f(x,y,z)=\underbrace{-u\log_2(u)-(1-u)\log_2(1-u)}_{g(u)}-y$

$g(u)$ is maximal for $\ln(u)=\ln(1-u)\iff u=\frac 12$

Now $u$ and $y$ are not independent variables but $y>0$ only reduces the overall $f$ value so the maximum is attained when $y=0$ and therefore $x=z=\frac 12$.

Note that you can calculate partial derivatives $f_x=g_x(u)$ and $f_y=g_y(u)-1$ and try to cancel the derivatives, but this leads to $g_x(u)=g_y(u)=0$ and $f_y=-1$, meaning there is no critical point.

The extremum is therefore met on the border (i.e. $y=0$ or $y=1$)