Q:

How to maximize the following function of two variables?

I have the following function:
\begin{equation}
f(q,p) = q \sqrt{p} + (1-q) \sqrt{1 - p}
\end{equation}
Here, $q \in [0,1]$ and $p \in [0,1]$.
Now, given some value $q \in [0,1]$ what value should I select for $p$ in order to maximize $f(q,p)$? That is, I need to define some function $g(q)$ such that $f(q, g(q))$ is a local maximum.
I've been thinking about this problem for days and I don't know where to begin. Any help will be greatly appreciated.

A:

By Cauchy-Schwarz,
$$
[q \sqrt{p} + (1-q) \sqrt{1 - p}]^2\leq(q^2+(1-q)^2)(p+1-p)=q^2+(1-q)^2.
$$
To have equality, we require
$$
\frac{\sqrt{p}}{\sqrt{1-p}}=\frac{q}{1-q}\iff \boxed{p=\frac{q^2}{1-2q+2q^2}}\in[0,1].
$$

