Third degree Taylor series of $f(x) = e^x \cos{x} $

Suppose you have the function: $$f(x) = e^x \cos{x} $$ and you need to find the 3rd degree Taylor Series representation. The way I have been taught to do this is to express each separate function as a power series and multiply as necessary for the 3rd degree. For example for $$ \cos x =\sum_{n=0}^\infty (-1)^n\frac{ x^{2n}}{(2n)!} = 1-\frac{x^2}{2!}+\frac{x^4}{4!}+\cdots \text{ and } e^x =\sum_{n=0}^\infty \frac{x^n}{n!} = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!}+\cdots $$ multiply the terms on the right of each until you get the 3rd degree.

Logically, I am happy. However, I have not seen a theorem or any rule that says you can just multiply series in this way. Doing it this way, is there a guarantee that I will always get the power series representation of $f(x)$?

Additionally, if instead of multiplying, functions were being added? Would the above hold true - take the series of each function and add up the necessary terms?


Taylor's theorem allows you to use the Big O notation: $$\cos(x)= 1-\frac{x^2}{2!}+O(x^4)\quad\mbox{and}\quad e^x=1 + x + \frac{x^2}{2!} + \frac{x^3}{3!}+O(x^4).$$ Therefore $$e^x\cos(x)=1 + x + \frac{x^2}{2!} + \frac{x^3}{3!}+O(x^4)-\frac{x^2}{2!}(1+x+O(x^2))=1+x-\frac{x^3}{3}+O(x^4).$$


Alternatively, you can directly expand the given function $f(x)=e^x\cos x$ to the Taylor series: $$\begin{align}f(0)=&1 \\ f'(x)=e^x\cos x-e^x\sin x \Rightarrow f'(0)=&1;\\ f''(x)=-2e^x\sin x \Rightarrow f''(0)=&0; \\ f'''(x)=-2e^x\sin x-2e^x\cos x \Rightarrow f'''(0)=&-2;\\ f^{(4)}=-4e^x\cos x \Rightarrow f''(0)=&-4 \end{align}$$ Hence: $$\begin{align}e^x\cos x=&1+\frac{1}{1!}x+\frac{0}{2!}x^2+\frac{-2}{3!}x^3+\frac{-4}{4!}x^4+O(x^5)=\\ =&1+x-\frac{x^3}{3}-\frac{x^4}{6}+O(x^5).\end{align}$$