<s>[INST] Why my calculations aren't right? (Maclaurin series) Good evening to everyone!
I tried to calculate $ \cos\left( x- \frac{x^3}{3} + o(x^4)\right) $ using the MacLaurin series but instead of getting the final result equal to $1 - \frac{x^2}{2}+\frac{3x^4}{8} + o(x^4)$ I got this:
$$
\cos\left( x- \frac{x^3}{3} + o(x^4)\right) = 1-\frac{\left(x-\frac{x^3}{3}+o\left(x^4\right)\right)^2}{4}+o\left(x^5\right) = 1-\frac{x^2+\frac{x^6}{9}+o\left(x^8\right)-\frac{2x^4}{3}+2xo\left(x^4\right)-\frac{2x^3o\left(x^4\right)}{3}}{4}+o\left(x^5\right) = 1-\frac{x^2}{4}+\frac{x^6}{36}-\frac{x^4}{6}+o\left(x^4\right)
$$
Where for expanding what's between the parenthesis I'm using the formula $(a-b+c)^2 = a^2+b^2+c^2-2ab+2ac-2bc $.
I would really want to know where I'm doing wrong. Thanks for any possible answers.
 [/INST] You are making two errors: (1) your series for $\cos x$ is wrong; (2) you are not treating the $x^4$ term correctly.
We have $\cos x=1-\frac{1}{2}x^2+\frac{1}{24}x^4+O(x^5)$. 
When we replace $x$ by $x-\frac{1}{3}x^3+O(x^5)$ the $\frac{1}{2}x^2$ gives us $\frac{1}{2}(x^2-\frac{2}{3}x^4)+O(x^5)=\frac{1}{2}x^2-\frac{1}{3}x^4+O(x^5)$.
All we get from the $\frac{1}{24}x^4$ term after the replacement is $\frac{1}{24}x^4+O(x^5)$.
So we have finally $\cos x=1-\frac{1}{2}x^2+\frac{3}{8}x^4+O(x^5)$.
</s>