What is the maximum of $\ 2(a+b)-ab$ if we have: $\ a^2+b^2=8\ (a,b\ real)$ What is the maximum of $\quad 2(a+b)-ab\ $ if we have: $a^2+b^2=8 \ (a,b\ real)  $
My work is as follows:
According to AM-GM inequality:
     $$\frac{a^2+b^2}2\ge\sqrt{a^2b^2} \Rightarrow $$
     $$ab\le4 $$
On the other hand , from  $\ a^2+b^2=8\ ,\  $we have:  $\ 2(a+b)-ab=2\sqrt{8+2ab}-ab$
We can get this:  $$2\sqrt{8+2ab}\le8$$
Is it possible to somehow combine these two inequalities to find the maximum value of $\ 2(a+b)-ab$ ?
I think in this solution technique we must find the minimum value of $ab\ $ , but how???

Using differentiation: Let $f(t)=2\sqrt{8+2t}-t$, then $f'(t)=\frac{2}{\sqrt{8+2t}}-1$. Then $f(t)$ increases when $-4<t<-2$ and decreases when $-2<t<4$. Thus $f(t)$ has a maximum at $t=-2$ and $f(-2)=2\sqrt{8-4}+2=6$. Since $|ab|\le 4$, $2(a+b)-ab$ has a maximum $6$.
Alternative method: Let $a=2\sqrt{2}\cos\theta$ and $b=2\sqrt{2}\sin\theta$, then
\begin{align}
2(a+b)-ab&=-4(\cos\theta+\sin\theta)^2+4\sqrt{2}(\cos\theta+\sin\theta)+4\\
&=-4((\cos\theta+\sin\theta)^2-\sqrt{2}(\cos\theta+\sin\theta)-1)\\
&=-4\left(\left(\cos\theta+\sin\theta-\frac{1}{\sqrt{2}}\right)^2-\frac{3}{2}\right)
\end{align}
Therefore, $2(a+b)-ab$ has maximum $6$ when $\sin\theta+\cos\theta=\frac{1}{\sqrt{2}}$.
