Integration by parts: $\int e^{-\theta}\cos7\theta \;d\theta$ $$\int e^{-\theta}\cos7\theta \;d\theta$$
I started off by using $u=\cos 7\theta$ and$ \;dv=e^{-\theta}d\theta$, however, this just led me in a circle.
I am now at:
$$u=e^{-\theta},\;dv=\cos 7\theta  \,d\theta$$
$$du=-e^{-\theta} d\theta, v=\frac17\sin 7\theta$$
$$uv-\int v\,du \Rightarrow \bigg(e^{-\theta}\bigg)\bigg(\frac17\sin 7\theta\bigg) - \int\bigg(\frac17\sin\;7\theta\bigg)\bigg(-e^{-\theta}\bigg)d\theta$$
$$\bigg(e^{-\theta}\bigg)\bigg(\frac17\sin 7\theta\bigg) - \frac17\int\bigg(\sin\;7\theta\bigg)\bigg(-e^{-\theta}\bigg)d\theta$$
and then I did:
$$u=-e^{-\theta},\;dv=\sin 7\theta\;d\theta$$
$$du=e^{-\theta},\;v=-\frac17\cos 7\theta$$
to get:
$$(-e^{-\theta})(-\frac17\cos 7\theta)-\int (-\frac17\cos 7\theta)(e^{-\theta})d\theta$$
I would assume (if I'm doing this right) that the next step would be to substitute as so:
$$\bigg(e^{-\theta}\bigg)\bigg(\frac17\sin 7\theta\bigg) - \bigg[(-e^{-\theta})(-\frac17\cos 7\theta)-\int (-\frac17\cos 7\theta)(e^{-\theta})d\theta\bigg]$$
which would be:
$$
\frac17e^{-\theta}\bigg[
\bigg(\sin 7\theta\bigg) 
-\bigg(\cos 7\theta\bigg)
-\bigg(\frac17\sin7\theta + C\bigg)\bigg]+C
$$
I'm (almost) certain that this is incorrect, so could someone point me in the right direction and maybe explain some of my errors?
 A: Hint: You are supposed to go in a circle!
Integrating by parts once gives:
$$\begin{align}
\int e^{-\theta}\cos{7\theta}\,\mathrm{d}\theta
&=e^{-\theta}\cos{7\theta}-\int e^{-\theta}\left(-7\sin{7\theta}\right)\,\mathrm{d}\theta\\
&=e^{-\theta}\cos{7\theta}+7\int e^{-\theta}\sin{7\theta}\,\mathrm{d}\theta\\
\end{align}$$
Integrating by parts again:
$$\begin{align}
\int e^{-\theta}\sin{7\theta}\,\mathrm{d}\theta
&=e^{-\theta}\sin{7\theta}-7\int e^{-\theta}\cos{7\theta}\,\mathrm{d}t
\end{align}$$
Thus,
$$\begin{align}
\color{blue}{\int e^{-\theta}\cos{7\theta}\,\mathrm{d}\theta}
&=e^{-\theta}\cos{7\theta}+7\int e^{-\theta}\sin{7\theta}\,\mathrm{d}\theta\\
&=e^{-\theta}\cos{7\theta}+7\left[e^{-\theta}\sin{7\theta}-7\int e^{-\theta}\cos{7\theta}\,\mathrm{d}t\right]\\
&=e^{-\theta}\cos{7\theta}+7e^{-\theta}\sin{7\theta}-\color{red}{49\int e^{-\theta}\cos{7\theta}\,\mathrm{d}t}\\
\end{align}$$
$$\implies \color{blue}{\int e^{-\theta}\cos{7\theta}\,\mathrm{d}\theta}+\color{red}{49\int e^{-\theta}\cos{7\theta}\,\mathrm{d}t}=e^{-\theta}\cos{7\theta}+7e^{-\theta}\sin{7\theta}.$$
Can you take it from there?
A: For the integrand $e^{-x}\cos\left(7x\right)$, integrate by parts, $\int fdg=fg-\int gdf$, where $f=\cos\left(7x\right)$, $dg=e^{-x}dx$, $df=-7\sin\left(7x\right)dx$, $g=-e^{-x}$:
$$\int e^{-x}\cos\left(7x\right)dx=-e^{-x}\cos\left(7x\right)-7\int e^{-x}\sin\left(7x\right)dx$$

Integrate by parts again, where $f=\sin\left(7x\right)$, $dg=e^{-x}dx$, $df=7\cos\left(7x\right)dx$, $g=-e^{-x}$:
$$\int e^{-x}\cos\left(7x\right)dx=7e^{-x}\sin\left(7x\right)-e^{-x}\cos\left(7x\right)-49\int e^{-x}\cos\left(7x\right)dx$$

Add $49\int e^{-x}\cos\left(7x\right)dx$ to both sides:
$$50\int e^{-x}\cos\left(7x\right)dx=7e^{-x}\sin\left(7x\right)-e^{-x}\cos\left(7x\right)$$

Divide both sides by 50:
$$\int e^{-x}\cos\left(7x\right)dx=\dfrac{1}{50}\left(7e^{-x}\sin\left(7x\right)-e^{-x}\cos\left(7x\right)\right)+C$$

$$\boxed{-\dfrac{1}{50}e^{-x}\left(\cos\left(7x\right)-7\sin\left(7x\right)\right)+C}$$
A: You do want to start at $u = \cos(7 \theta), \space dv = e^{-\theta}$. There is a nice trick you can use on these types of "circular" IBP problems. Using the substitution you initially tried, we have $$\int e^{-\theta}\cos(7 \theta)d\theta = -\cos(7 \theta)e^{-\theta}-\int-7\sin(7\theta)(-e^{-\theta}) d\theta \\ = -\cos(7 \theta)e^{-\theta}-7\int \sin(7\theta)e^{-\theta} d\theta$$ Now let's do another substitution for the integral on the far right, with $a = \sin(7\theta), \space db = e^{-\theta}$. We will get $$\int \sin(7\theta)e^{-\theta} d\theta = -\sin(7\theta)e^{-\theta}-\int 7\cos(7\theta)(-e^{-\theta}) \\ =  -\sin(7\theta)e^{-\theta}+7\int \cos(7\theta)e^{-\theta}d\theta$$ But now the integral on the far right is exactly the same as the one we started with, as you noticed. Let's plug in the result we just got into the first integral equation we have. $$\int e^{-\theta}\cos(7 \theta)d\theta= -\cos(7 \theta)e^{-\theta}-7\int \sin(7\theta)e^{-\theta} d\theta \\ = -\cos(7 \theta)e^{-\theta}-7\left(-\sin(7\theta)e^{-\theta}+7\int \cos(7\theta)e^{-\theta}d\theta \right) \\ = -\cos(7 \theta)e^{-\theta}+7\sin(7\theta)e^{-\theta}-49\int \cos(7\theta)e^{-\theta}d\theta $$ Now we can add the quantity, "$\space 49\int \cos(7\theta)e^{-\theta}d\theta$" to both sides of the equation. $$\implies \space 50\int \cos(7\theta)e^{-\theta}d\theta =  -\cos(7 \theta)e^{-\theta}+7\sin(7\theta)e^{-\theta} \\ \implies \int \cos(7\theta)e^{-\theta}d\theta = \frac{1}{50}\left[ -\cos(7 \theta)e^{-\theta}+7\sin(7\theta)e^{-\theta} \right]+C$$ 
