# Integrating a function by representing it as a power series

I'm trying to integrate this function with power series

$$\int2\cos^2(x)e^{-x}\,\mathrm dx$$

Since I know the Maclaurin series for $$\cos(x)$$ is $$\sum_{n=0}^{\infty} \dfrac{(-1)^nx^{2n}}{(2n)!}$$ and $$e^x$$ is $$\sum_{n=0}^{\infty} \dfrac{x^{n}}{n!}$$ then

$$\int2\cos^2(x)e^{-x}\,\mathrm dx = \int2\left(\sum_{n=0}^{\infty} \dfrac{(-1)^nx^{2n}}{(2n)!}\right)^2 \left(\sum_{n=0}^{\infty} \dfrac{(-1)^nx^{n}}{n!}\right)\,\mathrm dx$$

However, I'm not certain that this is leading me forward. Usually these types of problems in early calculus involve representing the function under one sum and integrating the series as a polynomial. Is there something that I'm missing?

Hint: $$\cos^2x=\frac{1+\cos 2x}{2}$$ $$\cos(2x)e^{-x}= \left(\sum_{n=0}^{\infty} \dfrac{(-1)^n2^{2n}x^{2n}}{(2n)!}\right) \left(\sum_{m=0}^{\infty} \dfrac{(-1)^mx^{m}}{m!}\right)=\sum_{n=0}^{\infty}\sum_{m=0}^{\infty}\frac{(-1)^{n+m}2^{2n}x^{2n+m}}{(2n)!m!}{}$$
• Thanks! However, I'm still stuck a bit later. By simplifying I get $\int e^{-x}+cos(2x)e^{-x}dx$ which can be split into two integrals $\int e^{-x} dx+ \int cos(2x)e^{-x}dx$. The first one is quite simple for me, but not the second one. Representing it as a power series I get $$\int\cos(2x)e^{-x}\,\mathrm dx = \int\left(\sum_{n=0}^{\infty} \dfrac{(-1)^n2^{2n}x^{2n}}{(2n)!}\right) \left(\sum_{n=0}^{\infty} \dfrac{(-1)^nx^{n}}{n!}\right)\,\mathrm dx$$ Its a bit better than what we had previously but there is still a product of sums which I don't see how to remove. – Cedric Martens Apr 25 '19 at 20:20
• Use a generalized case of the distributive property: $$\left(\sum_{i} a_{i}\right)\left(\sum_{j}b_{j}\right)=\sum_{i}\left(a_{i}\sum_{j}b_{j}\right)=\sum_{i}\sum_{j} a_{i}b_{j}$$ The order of the summations is interchangeable in the last step. – Mathematically Encrypted Jul 5 at 16:35