How come $\frac{1}{\cos x} = 1 + \frac{x^{2}}{2} + o(x^{2})$ as $x \to 0$? Since 
$$\cos x = 1 - \frac{x^{2}}{2} + o(x^{3})$$
as 
$x \to 0,$
we have
$$\frac{1}{\cos x} = \frac{1}{1-\frac{x^{2}}{2} + o(x^{3})} = 1 + \frac{x^{2}}{2} + o(x^{3}) + o(\frac{-x^{2}}{2} + o(x^{3})).$$
But I do not see how to write the term on the extreme right as $o(x^{2})$.

You may recall that
$$
\frac{1}{1-u}=1+u+O(u^2), \quad u \to 0.
$$
Thus
$$
\frac{1}{\cos x} = \frac{1}{1-\frac{x^{2}}{2} + o(x^{3})} = 1 + \frac{x^{2}}{2} + o(x^{3}) + O(\frac{-x^{2}}{2} + o(x^{3}))^2
$$ then use
$$
O(\frac{-x^{2}}{2} + o(x^{3}))^2 =o(x^{3}).
$$
