# integration by parts of trig function

I tried to solve the integral below using integration by parts $$\int_0^t\cos(x)\cos(t-x)dx=\frac{1}{2}(\sin(t)+t\cos(t))$$

It seemed solvable through doing integration by parts twice, but it hasn't worked for me yet... tcos(t) doesn't come up!

I know how it can be solved using properties of trig function, why can't it be solved by integration by parts?

• What steps did you use for your integration by parts? In particular, where did the $\cdots+t \cdots$ come from? – Henry Jul 6 '18 at 12:43

You can do it by integration by parts, but you have to start off in a slightly funny direction to stop the final integral cancelling with the original: $$I = \int_0^t 1 \cdot \cos{x}\cos{(t-x)} \, dx = [x\cos{x}\cos{(t-x)}]_0^t - \int_0^t x(-\sin{x}\cos{(t-x)}+\cos{x}\sin{(t-x)}) \, dx \\ = t\cos{t} + \int_0^t x(\sin{x}\cos{(t-x)}-\cos{x}\sin{(t-x)}) \, dx,$$ giving something that looks like one of the terms. Now integrate the first term in the integral by parts, $$\int_0^t x\sin{x}\cdot \cos{(t-x)} \, dx = [-x\sin{x}\sin{(t-x)}]_0^t + \int_0^t (x\cos{x}-\sin{x}) \sin{(t-x)} \, dx.$$ The first term in the remaining integral cancels with the second term in the integral from the first integration by parts, so $$\int_0^t \cos{x}\cos{(t-x)} \, dx = t\cos{t} - \int_0^t \sin{x}\sin{(t-x)} \, dx.$$ To deal with the remaining integral we integrate by parts again: $$- \int_0^t \sin{x}\sin{(t-x)} \, dx = [\cos{x}\sin{(t-x)}]_0^t-\int_0^t \cos{x}\cos{(t-x)} \, dx \\ = \sin{t}-I,$$ so $$I = t\cos{t}+\sin{t}-I,$$ or $$I = \frac{1}{2}(t\cos{t}+\sin{t}),$$ as expected.

It was not at all obvious that this would work. In general, $$\int fg' \, dx = xfg' - \int x(f'g'+fg'') \, dx \\ = x(fg' - f'g) + \int [(xf''+f')g-xfg''] \, dx \\ = x(fg'-f'g) + fg-\int fg' \, dx + \int x(f''g-fg'') \, dx,$$ so $$\int fg' \, dx = \frac{1}{2}(x(fg'-f'g)+fg)+\frac{1}{2}\int x(f''g-fg'') \, dx,$$ and it so happens that in this case the integral on the right vanishes (as it will for any two solutions to a differential equation of the form $y''+q(x)y=0$, since $f''g-fg''$ is the derivative of the Wronskian, and this vanishes since the coefficient of $y'$ is zero).

A way to do this without a strange integration by parts is to look at $$\lim_{a \to 1} \int_0^t \cos{ax}\cos{(t-x)} \, dx:$$ the integral and the limit can be interchanged because everything is continuous and the limit function is continuous, but $\int_0^t \cos{ax}\cos{(t-x)} \, dx$ can be done by parts in the usual way: we find $$\int_0^t \cos{ax}\cos{(t-x)} \, dx = \dotsb = \sin{t}-a\sin{t} + \int_0^t \cos{ax}\cos{(t-x)} \, dx,$$ so $$\int_0^t \cos{ax}\cos{(t-x)} \, dx = \frac{\sin{t}+a\sin{at}}{1-a^2},$$ and taking the limit gives the result (although will require some trig identities).

• And yes, I did guess the form of the integration by parts from the answer. I'm not suggesting that one would necessarily just spot this as the right way to go initially. – Chappers Jul 6 '18 at 22:28
• Thank you. but Why is it that f and g should be 1 and cosxcos(t−x) to solve this by integration by parts? I mean, why can't I see f and g as cosx and cos(t−x)? – NK Yu Jul 8 '18 at 13:32
• The relationship between the first and second calculations is that $f(x)=\cos{x}$ and $g(x) = -\sin{(t-x)}$ (so $g'(x) = \cos{(t-x)}$). We then see that the first calculation works because this $f$ and $g$ both solve $y''+y=0$. – Chappers Jul 8 '18 at 13:50
• I think I get what you mean. What I wanna ask you is how seeing f and g as cosx and cos(t−x) makes it not solvable. Is it just coincidence or is there something I should know about? – NK Yu Jul 9 '18 at 7:05
• There's no particular reason that it doesn't work: you simply end up duplicating the original integral with the same sign on the other side, so you end up with everything cancelling out rather than producing an expression that can be rearranged to solve for $I$. Also, since the answer has a $t$ in it, no number of integrations or differentiations of the trig functions as they are (without using identities) will produce the right form for the answer. – Chappers Jul 14 '18 at 20:26

Hint: use the formula

$$\cos(x)\cos(y)=\frac{1}{2}(\cos(x-y)+\cos(x+y))$$ for your Control: $$1/2\,\sin \left( t \right) +1/2\,\cos \left( t \right) t$$

I’m going to guess you haven’t learned about Laplace transforms or convolutions, as you didn’t recognize it in this case, but the form of the integral is such that it is

$$\cos(t)*\cos(t)$$

Where $*$ is the convolution operator

In such case the answer is obtained by

$$\mathcal{L}^{-1}\left(\left({\frac{s}{s^2+1}}\right)^2\right)$$

$$=\frac{1}{2}(\sin(t)+t\cos(t))$$

First you can observe that

$\cos(x)\cos(t-x)-\sin(x)\sin(t-x)=$

$=\cos(x+(t-x))=\cos(t)$

so

$\cos(x)\cos(t-x)=\cos(t)+\sin(x)\sin(t-x)$

Then

$\int_0^t \cos(x)\cos(t-x)dx =$

$=\int_0^t \cos(t)dx +\int_0^t \sin(x)\sin(t-x)dx=$

and using integration by parts you have that

$=t \cos(t)+[\sin(x)\cos(t-x)]_0^t-\int_0^t \cos(x)\cos(t-x)dx=$

$=t \cos(t)+\sin(t)-\int_0^t \cos(x)\cos(t-x)dx$

so

$2\int_0^t \cos(x)\cos(t-x)dx =t \cos(t)+\sin(t)$

and

$\int_0^t \cos(x)\cos(t-x)dx =\frac{1}{2}(t \cos(t)+\sin(t))$

• I think your have some trailing equal signs you forgot to remove? – jpmc26 Jul 6 '18 at 21:10
• Another way! awsome. Could you explane why cosxcos(t−x) should be converted to the mentioned form? What makes seeing f and g as cosx and cos(t−x) insolvable? – NK Yu Jul 8 '18 at 13:37

\begin{align} \int_o^t{\cos(x)\cos(t-x)dx} &= \displaystyle{ 1 \over 2}\int_o^t[\cos(2x-t)+\cos(t)]dx \\ &= \displaystyle{ 1 \over 2}t\cos(t) + \displaystyle{ 1 \over 2} \int_o^t{\cos(2x-t)}dx \\ &= \displaystyle{ 1 \over 2}t\cos(t) + \displaystyle{ 1 \over 4}\sin(2x-t)\Big|_{0}^{t} \\ & =\displaystyle{ 1 \over 2}(\sin(t)+t\cos(t)) \end{align}

You have the last equality since $\sin(-t)=-\sin(t)$