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: Hint:
Now we take some constant $q$ so our function becomes a function with only $p$ varying:
$$\begin{equation}
f(p) = q \sqrt{p} + (1-q) \sqrt{1 - p}
\end{equation}$$
With the constraint $0 \leq p \leq 1$. To maximize one must consider critical points in our interval, and the endpoints. Keep in mind that the constant $q$ is somewhere between $0$ and $1$.
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].
$$
A: We have that 
$$\nabla f=\left(\sqrt{p}-\sqrt{1-p},\frac{q}{2\sqrt p}-\frac{1-q}{2\sqrt{1-p}}\right)$$ doesn't vanish on $(0,1)\times (0,1).$ Thus the maximum is achieved on the boundary. Now we have
\begin{cases}f(0,p)&=1-p\\f(1,p)&=p\\f(q,0)&=\sqrt{1-q}\\ f(q,1)&=\sqrt{q}\end{cases}
So we have $$f(0,0)=f(1,1)=1>f(x,y), \forall (x,y)\in [0,1]\times [0,1]\setminus \{(0,0),(1,1)\}.$$
To maximize $f(p,q)$ for a given $q$ we consider $g(p)=q\sqrt{p} + (1-q) \sqrt{1 - p}$ with $q$ constant. Then $g'(p)\ne 0, \forall p\in (0,1).$ So the maximum value is among
$$f(q,0)=1-q,  f(q,1)=q.$$
