How to prove that the following function is maximized when $p = q$? Given the following function:
\begin{equation}
f(q,p) = q\log(2p) + (1 - q)\log(2 - 2p)
\end{equation}
Given some $q \in [0,1]$ we need to prove that $f(q, p)$ is maximized when $p = q$. How to prove this?
 A: Since $q\in[0,1]$ is given we have to study the function
$$g_q(p):=q\log p+(1-q)\log(1-p)+\log 2$$
on the interval $0\leq p\leq1$. One has
$g_0(p)=\log (1-p)$, which is maximal at $p=0$, as claimed, and similarly $g_1(p)=\log p$ is maximal at $p=1$.
When $0<q<1$ then both $\lim_{p\to0+} g_q(p)=-\infty$, $\lim_{p\to1-} g_q(p)=-\infty$. Hence the function $g_q$ assumes its maximum at an interior point $p_*\in\>]0,1[\>$, which will be brought to the fore by letting
$$g_q'(p)={q\over p}-{1-q\over 1-p}={q-p\over p(1-p)}=0\ .$$It follows that $p_*=q$, as claimed.
A: Take the gradient
$$
\nabla f(p,q)=\left(\log(2p)-\log(2(1-p)),\frac qp-\frac{(1-q)}{(1-p)}\right)
$$
and putting this equal to $(0,0)$; thus you get
$$
\log(2p)=\log(2(1-p))\\
\frac qp=\frac{(1-q)}{(1-p)}
$$
i.e.
\begin{align*}
p&=1-p\;\;\Longrightarrow p=1/2\\
q/(1/2)&=(1-q)/(1/2)\;\;\Longrightarrow q=1/2\;\;.
\end{align*}

Let's instead consider the following problem: fixed $q\in[0,1]$, maximize $p\mapsto f(p,q)$ on $[0,1]$.
Let's thus consider the $p$-derivative:
$$
\partial_pf(p,q)=\log(2p)-\log[2(1-p)]
$$
which is zero iff $p=1-p$, i.e. $p=1/2$
