# Integration by parts: $\int e^{ax}\cos(bx)\,dx$

I need to evaluate the following function and then check my answer by taking the derivative: $$\int e^{ax}\cos(bx)\,dx$$ where $a$ is any real number and $b$ is any positive real number.

I know that you set $u=\cos(bx)$ and $dv=e^{ax} dx$, and the second time you need to integrate again you set $u=\sin(bx)$ and $dv=e^{ax}dx$ again.

It eventually simplifies down to $$\int e^{ax}\cos(bx)dx = \frac{1}{a}e^{ax}\cos(bx) + \frac{b}{a}\left(\frac{1}{a}e^{ax}\sin(bx) - \frac{b}{a}\int e^{ax}\cos(bx)\,dx\right).$$

Now I know to move the integral on the left side to the right side so that I can just divide by the constant to solve.

Here is my problem:

I know I need to solve the right side to be: $$\frac{e^{ax}\left(a\cos(bx) + b\sin(bx)\right)}{a^2+b^2} + C.$$

To divide by the constant, I multiplied everything on the right side by $$\frac{a^2}{b^2+1}.$$ but this leads me to get $b^2 + 1$ on the bottom instead of $a^2 + b^2$.

I will show what I am doing in detail:

After setting the initial integral equal to: $$\frac{1}{a}e^{ax}\cos(bx) + \frac{b}{a}\left(\frac{1}{a}e^{ax}\sin(bx) - \frac{b}{a}\int e^{ax}\cos(bx)\,dx\right) + C$$ I simplify: $$\int e^{ax}\cos(bx)\,dx = \frac{a^2}{b^2+1}\left(\frac{1}{a}e^{ax}\cos(bx) + \frac{b}{a}\left(\frac{1}{a}e^{ax}\sin(bx)\right)\right) + C$$

If this is already wrong, can someone point be in the right direction?

If I have not gone wrong yet, I can edit to show the rest of my work.

• The short answer (since I already posted the long one (-; ): you got the constant wrong. – Arturo Magidin Feb 8 '11 at 6:34
• – Workaholic Mar 11 '16 at 17:27

So you have $$\int e^{ax}\cos(bx)dx = \frac{1}{a}e^{ax}\cos(bx) + \frac{b}{a}\left(\frac{1}{a}e^{ax}\sin(bx) - \frac{b}{a}\int e^{ax}\cos(bx)\,dx\right).$$ Multiplying out you get $$\int e^{ax}\cos(bx)\,dx = \frac{1}{a}e^{ax}\cos(bx) + \frac{b}{a^2}e^{ax}\sin(bx) - \frac{b^2}{a^2}\int e^{ax}\cos(bx)\,dx.$$ At this point, you should move that last integral on the right hand side to the left hand side and add in the constant of integration on the right.

Moving the last integral to the left hand side, you get $$\left(1 + \frac{b^2}{a^2}\right)\int e^{ax}\cos(bx)\,dx = \frac{1}{a}e^{ax}\cos(bx) + \frac{b}{a^2}e^{ax}\sin(bx) + C,$$ and I think this is where you made your mistake.

You tried to clear that $1 + \frac{b^2}{a^2}$ by multiplying through by $\frac{a^2}{1+b^2}$. But this is incorrect: $$1 + \frac{b^2}{a^2} = \frac{a^2+b^2}{a^2} \neq \frac{1+b^2}{a^2}$$ so that what you multiplied through did not clear that factor. You need to multiply by $\frac{a^2}{a^2+b^2}$ (or, more horribly, by $$\frac{1}{1+\frac{b^2}{a^2}}$$ which is too horrible for words) for things to cancel out.

If you do that, from $$\frac{a^2+b^2}{a^2}\int e^{ax}\cos(bx)\,dx = \frac{1}{a}e^{ax}\cos(bx) + \frac{b}{a^2}e^{ax}\sin(bx) + C,$$ multiplying both sides by $\frac{a^2}{a^2+b^2}$, we get: $$\int e^{ax}\cos(bx)\,dx = \frac{a}{a^2+b^2}e^{ax}\cos(bx) + \frac{b}{a^2+b^2}e^{ax}\sin(bx) + C$$ the intended answer.

By the way: you don't need to have the "$+C$" on the right hand side until there are no more indefinite integrals there; the constant of integration is implicit in the indefinite integral, so for example, in your penultimate displayed equation, the "$+C$" is superfluous.

• Thank you so much, you are a life-saver. Could you just prove quick how you get from: $$1 + \frac{b^2}{a^2} = \frac{a^2+b^2}{a^2}$$ So I don't have to try to multiply by: $$\frac{1}{1+\frac{b^2}{a^2}}$$ – Finzz Feb 8 '11 at 6:40
• @Finzz: (I think you mean, how did I get from $1+\frac{b^2}{a^2}$ to $\frac{a^2+b^2}{a^2}$, not how I got form the equation to... well, nowhere, you didn't say to where... (-; ) I just did the operation:$$1+\frac{b^2}{a^2} = \frac{a^2}{a^2}+\frac{b^2}{a^2} = \frac{a^2+b^2}{a^2}.$$So to clear $\frac{a^2+b^2}{a^2}$, we multiply through by its reciprocal, $\frac{a^2}{a^2+b^2}$. – Arturo Magidin Feb 8 '11 at 6:43
• @Finzz: And now, I'm afraid I'm going to bed; almost 1am here, and I need to get up about three hours before my first class at 9am. – Arturo Magidin Feb 8 '11 at 6:44
• Yes, that is what I meant. Thanks a bunch and sweet dreams. – Finzz Feb 8 '11 at 6:52

Another solution to your original question can be using complex numbers. \begin{align} I&=\displaystyle\int e^{ax}\cos {bx}dx \\ &=\Re\left(\displaystyle\int e^{ax}(\cos {bx}+i\sin {bx})\right)dx\\ &=\Re\left(\displaystyle\int e^{(a+ib)x}dx\right)\\ &=\Re\left(\dfrac{e^{(a+ib)x}}{a+ib}\right)\\ &=\Re\left(\dfrac{e^{ax}(\cos {bx}+i\sin {bx})}{a+ib}\right)\\ &=\Re\left(\dfrac{e^{ax}}{a^2+b^2}(\cos {bx}++i\sin {bx})(a-ib)\right)+C\\ \therefore I&=\dfrac{e^{ax}}{a^2+b^2}(a\cos {bx}+b\sin {bx})+C \end{align}

• – marty cohen Jan 3 '15 at 19:08
• Does this argument work for imaginary a? – jm22b Feb 26 '17 at 18:13