Why does this series expansion for $\frac{1}{\cos(x)}$ fail using $\frac{1}{1-x}$? I'm trying to do (2nd order) Taylor expansion for 
$$\frac{1}{\cos(x)}$$ using $$\frac{1}{1-x}$$
What I do is write
$$\cos(x)=1-\frac{x^2}{2!}+\frac{x^4}{4!}+ \cdot\cdot\cdot, \text{ at } x_0=0$$
and
$$\frac{1}{1-x}=1+x+x^2+\cdot\cdot\cdot$$
so
$$\frac{1}{\cos(x)}=\frac{1}{1-(1-\cos(x))}=1+(1-\cos(x))+(1-\cos(x))^2$$
$$=1+(1-1+\frac{x^2}{2!})+(1-1+\frac{x^2}{2!})^2$$
$$=1+\frac{1}{2}x^2+\frac{1}{4}x^4$$
which is correct up to order 2 (or order 1?), but the coefficient of $x^4$ (is that 3rd or 4th order?) is wrong.
Why? How can I get the correct coefficients for higher orders?
And if I do want only 2nd order Taylor polynomial, then what is the term $\frac{1}{4}x^4$?
 A: Why do you make things more complex than what they are?
If you want the expansion of this function, say up to order $6$, simply write $\;\dfrac1{\cos x}=\dfrac1{1-\dfrac{x^2}2+\dfrac{x^4}{24}-\dfrac{x^6}{720}+o(x^7)}$, for instance, and set
$$u=\dfrac{x^2}2-\dfrac{x^4}{24}+\dfrac{x^6}{720}+o(x^7)$$
Now do the calculations for $\dfrac1{1-u}$ up to order $3$ (since the polynomial part of $u$ has order $2$), truncating the results for each power at order $6$:
\begin{alignat}{5}
1+u&=1+\frac{x^2}2&&-\frac{x^4}{24}&&+\frac{x^6}{720}&&+o(x^7)\\
{}+u^2&=&&+\frac{x^4}{4}&&-\frac{x^6}{24}&&+o(x^7)\\
{}+u^3&=&&&&+\frac{x^6}{8}&&+o(x^7)\\
\hline
\frac1{\cos x}&=1+\frac{x^2}2&&+\frac{5x^4}{24}&&+\frac{59x^6}{24}&&+o(x^7)
\end{alignat}
Alternatively, you can divide $1$ by $1-\dfrac{x^2}2+\dfrac{x^4}{24}-\dfrac{x^6}{720}$ by increasing powers (not the Euclidean division!) up to degree $6$.
A: You did not calculate the 3rd and 4th order coefficients like this, only the second (you have some $o(x^2)$ remaining from the first term, of which the $\frac{x^4}{4}$ is a part of).
In order to get the fourth (the third is null by parity), you need all terms that will give a fourth order coefficient, so that you are only left with some $o(x^4)$
In your case, for the fourth coefficient, it would be
$\frac{1}{cos(x)} =  1 + (1-1+\frac{x^2}{2!}-\frac{x^4}{4!} + o(x^4))+(1-1+\frac{x^2}{2!}-\frac{x^4}{4!} + o(x^4))^2$
$= 1 + \frac{x^2}{2!}-\frac{x^4}{4!} + \frac{x^4}{4} + o(x^4) = 1 + \frac{x^2}{2!}+\frac{5x^4}{24} + o(x^4)$
