For the function $f(X) = x+ \frac 1x$, if maxima is found using second derivative test we get $x=1$ as the answer. But isn't $x = -1 $ the answer? $$f(x) = x +\frac 1x$$
$$f'(x) = 1- x^{-2}=0 $$
$$\implies x= \pm 1$$
$$f''(x)= 2x^{-3}$$
$$f''(-1)<0$$
$$f''(1)>0$$
Therefore $x = 1 $ is the minimum.
but $f(1)= 2 > f(-1) =-2.$
which means $-1$ is the minimum. How is it possible?
Please explain if there is a mistake.
 A: You correctly used the Second Derivative Test to determine that the function 
$$f(x) = x + \frac{1}{x}$$
has a relative minimum at $x = 1$ and a relative maximum at $x = -1$.  You also found that the relative minimum value $f(1) = 1$ exceeded the relative maximum value $f(-1) = -1$, which you found confusing.  I suspect that the reason for your confusion is that you are confusing a relative extremum with an absolute extremum.  
What does it mean for a function to have a relative minimum value at $x = x_0$? 
It means that there is an open interval $I$ containing $x_0$ such that for each $x \in I$, $f(x_0) \leq f(x)$.  
In our example, $f(1) \leq f(x)$ for each $x \in (0, \infty)$.  One way to see this is to observe that 
$$f'(x) = 1 - \frac{1}{x^2}$$
is negative in $(0, 1)$, $0$ at $x = 1$, and positive in $(1, \infty)$, which means that the function decreases in the interval $(1, \infty)$, reaches its relative minimum value of $2$ at $x = 1$, and then increases in the interval $(1, \infty)$.  Alternatively, observe that for $x > 0$
\begin{align*}
(x - 1)^2 \geq 0\\
x^2 - 2x + 1 \geq 0\\
x^2 + 1 \geq 2x\\
x + \frac{1}{x} \geq 2
\end{align*}
with equality holding if and only if $x = 1$.
What it does not imply is that the function has an absolute minimum value at $x = x_0$.  
In our example,
$$\lim_{x \to 0^{-}} f(x) = \lim_{x \to 0^{-}} \left(x + \frac{1}{x}\right) = -\infty$$
and 
$$\lim_{x \to -\infty} f(x) =  \lim_{x \to -\infty} \left(x + \frac{1}{x}\right) = -\infty$$
so the function decreases without bound as $x \to 0^{-}$ or $x \to -\infty$.  Hence, $f(1) = 2$ is not an absolute minimum value of the function.
In particular, as you showed, $f(-1) = -2 < 2 = f(1)$.
What does it mean for a function to have a relative maximum at $x = x_0$?
It means that there is an open interval $I$ containing $x_0$ such that for each $x \in I$, $f(x_0) \leq f(x)$.
In our example, $f(-1) \geq f(x)$ for each $x \in (-\infty, 0)$.  To see this, observe that 
$$f(-x) = -x - \frac{1}{x} = -\left(x + \frac{1}{x}\right) = -f(x)$$
Since $f(x) \geq 2$ if $x > 0$ with equality holding if and only if $x = 2$, we may conclude that $f(x) \leq -2$ if $x < 0$ with equality holding if and only if $x = -2$.  
What it does not imply is that the function has an absolute maximum value at $x = x_0$.  
In our example,
$$\lim_{x \to 0^{+}} f(x) = \lim_{x \to 0^{+}} \left(x + \frac{1}{x}\right) = \infty$$
and 
$$\lim_{x \to \infty} f(x) =  \lim_{x \to \infty} \left(x + \frac{1}{x}\right) = \infty$$
so the function increases without bound as $x \to 0^{+}$ or $x \to -\infty$.  Hence, $f(-1) = -2$ is not an absolute maximum value of the function. 
In particular, as you showed, $f(1) = 2 > -2 = f(-1)$.
That said, perhaps the best way to see what is occurring is to draw the graph.  The graph of the function is shown in blue.  Its oblique asymptote, $y = x$, is shown in gray.  

