Cauchy–Schwarz inequality to find minimum of a function $$f(x) = x + \frac{2}{x}$$
I tried to find the minimum of $f(x)$ with the Cauchy–Schwarz inequality,
but I find different answers.  
First I suppose $a = (\sqrt{\frac{2}{x}} ,\sqrt x,0)$ and 
$b = (\sqrt x,\sqrt{\frac{2}{x}} ,0)$ and the minimum of function becomes $2\sqrt 2$.
Second I suppose $a = (\sqrt{\frac{2}{x}} ,\sqrt x,0)$ and 
$b = (\sqrt x,0 ,\sqrt{\frac{2}{x}})$ and the minimum of function becomes $\sqrt 2$. 
I know the first answer is true and in the second condition the inequality doesn't have a problem but it's not the minimum of the function.  
Do we know from this we can't use the Cauchy–Schwarz inequality to find the minimum of a function?
 A: We can use the CS-inequality to find the min of this function. You have actually already done most of the work. Both of your results say "whatever value of $x$ you put in, $f$ can't be smaller than this", and they're both right.
Now, to find the actual min, you have to remember when the CS inequality is an equality. That happens when the two vectors are parallel. In the second attempt, the two vectors can never be parallel, and as such, the function value can never actually get as low as $\sqrt 2$.
However, in your first attempt, there is a value of $x$ that makes the two vectors parallel, and that's $x = \sqrt2$, making both $a$ and $b$ into $(\sqrt[4]2, \sqrt[4]2, 0)$ and thus parallel. So the lower bound you got in your first attempt is actually attainable, and therefore the true minimum value of the function.
A: Yes, we can definitely know that whether this is correct sharp bound to the function or not. That is, whether the minimum value found is possible to attain or not.
For this, you need to apply the condition for equality for Cauchy-Schwarz and check whther it's possible or not. 
A: Option:
Use $AM+GM$ inequality:
For $x >0:$
$x+\dfrac{2}{x} \ge 2 \sqrt{x(2/x)} = 2√2.$
The minimum is attained for $x=2/x$, i.e.
for $x =√2.$
