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?

• Hint: The Taylor series converge uniformly and absolutely on any interval $[-a,a]$ where $a<R$. Then, you have tons of theorems you can use. – Michael Burr Apr 3 '18 at 16:35
• The product of two series, one of which is absolutely convergent, converges. Look up Cauchy Product. For example, en.wikipedia.org/wiki/Cauchy_product gets you started. Since the Taylor series are both absolutely convergent... – James S. Cook Apr 3 '18 at 23:45

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}

You can use the real part of $e^{(1+i)x}$. As the powers of $1+i$ are $$1,1+i,2i,-2+2i,-4,-4-4i,-8i\cdots$$ you write immediately $$e^x\cos x= 1+x-\frac{x^3}3-\frac{x^4}6-\frac{x^5}{30}+\cdots$$

Using the polar form, the general term is

$$\frac{(1+i)^n}{n!}x^n=\frac{\sqrt2^n\cos\frac{n\pi}{4}}{n!}x^n.$$

• Straight version of Marty Cohen's answer. This method is very efficient. – Yves Daoust Apr 5 '18 at 18:58
• And, of course, also gives you $e^x \sin x$. – marty cohen Apr 5 '18 at 21:36

$\begin{array}\\ f(x) &= e^x \cos{x}\\ &= e^x Re(e^{ix})\\ &= Re(e^{x+ix})\\ &= Re(e^{x(1+i)})\\ &= Re(\sum_{n=0}^{\infty} \dfrac{x^n(1+i)^n}{n!})\\ &= Re(\sum_{n=0}^{\infty} \dfrac{2^{n/2}x^ne^{i\pi n/4}}{n!})\\ &= Re(\sum_{n=0}^{\infty} \dfrac{2^{n/2}x^n(\cos(\pi n/4)+i\sin(\pi n/4))}{n!})\\ &= \sum_{n=0}^{\infty} \dfrac{2^{n/2}x^n\cos(\pi n/4)}{n!}\\ &= \sum_{n=0}^{\infty} \dfrac{2^{n/2}x^n[1, 1/\sqrt{2}, 0, -1/\sqrt{2}, -1, -1/\sqrt{2}, 0, 1/\sqrt{2}]}{n!}\\ &= \sum_{n=0}^{\infty} \dfrac{2^{\lfloor n/2 \rfloor}x^n[1, 1, 0, -1, -1, -1, 0, 1]}{n!}\\ &=1+x+0x^2-2x^3/6-4x^4/24-4x^5/120+...\\ &=1+x-x^3/3-x^4/6-x^5/30+...\\ \end{array}$

• Sorry, I can't understand your notation. – Yves Daoust Apr 5 '18 at 18:46
• $[1, 1, 0, -1, -1, -1, 0, 1]$ means $1*x^0+1*x^1-1*x^3-1*x^4-1*x^5+1*x^7$ with the coefficients repeated for subsequent exponents. – marty cohen Apr 5 '18 at 20:19
• I get it now. You take the $n\bmod8^{th}$ component of the tuple. Actually this approach is both faster and more general than the "winning" answer. – Yves Daoust Apr 5 '18 at 20:45

About the product of Taylor series.

In the development of the product

$$f(x)g(x)=\left(\sum_n\frac{f^{(n)}(0)}{n!}x^n\right)\left(\sum_m\frac{g^{(m)}(0)}{m!}x^m\right)=\sum_n\sum_m\frac{f^{(n)}(0)}{n!}\frac{g^{(m)}(0)}{m!}x^{n+m},$$

the terms of degree $n+m=d$ can be grouped as

$$\sum_{n+m=d}\frac{f^{(n)}(0)}{n!}\frac{g^{(m)}(0)}{m!}x^{d} =\sum_{n}\frac{f^{(n)}(0)}{n!}\frac{g^{(d-n)}(0)}{(d-n)!}x^{d} =\sum_{n}\binom dnf^{(n)}(0)g^{(d-n)}(0)\frac{x^{d}}{d!}.$$

Compare this to the Leibniz product rule:

$$(f(x)g(x))^{(d)}=\sum_n\binom dnf^{(n)}(x)g^{(d-n)}(x)$$

and you obtain

$$\left.\left(f(x)g(x)\right)^{(d)}\right|_{x=0}\frac{x^{d}}{d!}.$$