Find $a^2+b^2+2(a+b)$ minimum if $ab=2$ Let $a,b\in R$,and such 
$$ab=2$$
Find the minimum of the $a^2+b^2+2(a+b)$.
I have used $a=\dfrac{2}{b}$, then
$$a^2+b^2+2(a+b)=\dfrac{4}{b^2}+b^2+\dfrac{4}{b}+2b=f'(b)$$
Let $$f'(b)=0,\,b=-\sqrt{2}$$
So $$a^2+b^2+2(a+b)\ge 4-4\sqrt{2}$$
I wanted to know if there is other way to simplify the function and find the required value without using messy methods. Can we cleanly use AM-GM inequality?
 A: AM-GM inequality is (at least usually) only applied to positive real numbers.
Therefore I first consider the region $a>0,b>0$.
You can also write
$$
\begin{aligned}
f(a,b)&=a^2+b^2+2(a+b)\\
&=(a+b)^2+2(a+b)-2ab\\
&=s^2+2s-4,
\end{aligned}
$$
where $s=a+b$.
By the AM-GM inequality $s\ge 2\sqrt2$ with equality only when $a=b=\sqrt2$.
Here
$$
g(s)=s^2+2s-4
$$
is an increasing function of $s$ in the interval $s\in[2\sqrt2,\infty)$ (this is kinda obvious, but you can also check that $g'(s)>0$ in this interval). Therefore its smallest value is attained at $s=2\sqrt2$.
So if $a$ and $b$ are positive, the smallest value of $f$ is
$$
f(a,b)=f(\sqrt2,\sqrt2)=g(2\sqrt2)=4+4\sqrt2.
$$
The other possibility is that $a<0,b<0$. In that case AM-GM inequality (applied to $-a$ and $-b$) gives that $a+b\le-2\sqrt2$. Because the function
$g(s)$ is decreasing in the interval $s\in(-\infty,-2\sqrt2]$ it attains its smallest value at $s=-2\sqrt2$, i.e. at the point $a=b=-\sqrt2$. So if you allow negative values for $a$ and $b$, then the minimum is 
$$
f(-\sqrt2,-\sqrt2)=4-4\sqrt2
$$
A: For $a=b=-\sqrt2$ we get a value $4-4\sqrt2$.
We'll prove that it's a minimal value.
Indeed, let $a+b=2k\sqrt{ab}$. 
Hence, $|k|=\left|\frac{a+b}{2\sqrt{ab}}\right|\geq1$ and we need to prove that
$$a^2+b^2+2(a+b)\geq4-4\sqrt2$$ or
$$a^2+b^2+\sqrt{2ab}(a+b)\geq(2-2\sqrt2)ab$$ or
$$(a+b)^2+\sqrt{2ab}(a+b)\geq(4-2\sqrt2)ab$$ or
$$4k^2+2\sqrt2k\geq4-2\sqrt2$$ or
$$(k+1)(2k-2+\sqrt2)\geq0,$$
which is obvious for $|k|\geq1$.
Done!
A: Using AM-GM:
$$a^2+b^2+2(a+b)\ge 2ab+2(a+b)=4+2(a+b).$$
If $a,b>0,$ then $a+b \to min$ subject to $ab=2$. Using AM-GM: $a+b\ge 2\sqrt{ab}=2\sqrt{2}.$ Hence: $4+4\sqrt{2}$ is min.
If $a,b<0,$ then $a+b \to max$ subject to $ab=2.$ Maximize $f(a)=a+\frac2a$ to get $a=b=-\sqrt{2}$. Hence: $4-4\sqrt{2}$ is min.
