I'm looking for a quick and elegant way to calculate the integral: $$\int x\sin ax \cos x\, dx$$

It's doable by using $$\cos x=\frac{e^{ix}+e^{-ix}}2, ~~\sin ax=\frac{e^{iax}-e^{-iax}}{2i},$$ and then integrating by parts, but I find that solution too long and brute-force. Can you solve it alternatively?

Edit: $$\sin ax\cos x=\frac{\sin (a+1)+\sin (a-1)x}2$$ does the trick.


Use Werner formula:

$$2\sin A\cos B=\sin(A+B)+\sin(A-B)$$

Now integrate by parts $$\int x\sin(px)\ dx=x\int\sin(px)\ dx-\int\left(\dfrac{dx}{dx}\int\sin(px)\ dx\right)dx$$

OR as $$\dfrac{d(x\cos(px))}{dx}=\cos(px)-px\sin(px)$$

Integrate both sides, $$x\cos(px)+K=\int\cos(px)\ dx-p\int x\sin(px)\ dx$$


Just with some (mild) trigonometry to linearise : $$\sin ax\,\cos x=\frac12\bigl(\sin(a+1)x+\sin(a-1)x\bigr),$$ then integration by parts to remove the $x$ factor.


If you don't have trig identities at your fingertips, note that

$$\int x\sin ax\cos x\,dx=-{dI\over da}$$


$$I(a)=\int\cos ax\cos x\,dx$$

Integration by parts twice tells us

$$\begin{align} I(a) &=\cos ax\sin x+a\int\sin ax\sin x\,dx\\ &=\cos ax\sin x-a\sin ax\cos x+a^2\int\cos ax\cos x\,dx\\ &=\cos ax\sin x-a\sin ax\cos x+a^2I(a) \end{align}$$


$$I(a)={\cos ax\sin x-a\sin ax\cos x\over1-a^2}$$

and thus

$$\begin{align} \int x\sin ax\cos x\,dx &={(1-a^2)(-x\cos ax\sin x-\sin ax\cos x-ax\cos ax\cos x)+2a(\cos ax\sin x-a\sin ax\cos x)\over(1-a^2)^2}\\ &={(a^2x-x+2a)\cos ax\sin x-(a^2+1)\sin ax\cos x+a(a^2-1)\cos ax\cos x\over(1-a^2)^2} \end{align}$$

Remark: At the end of all this, one should add the obligatory "constant" of integration $C$, which in this case is a function, $C(a)$. Among other things, the constant of integration can help reconcile two different-looking answers obtained by two different approaches to evaluating the integral. (Its main purpose is to ensure you don't have points taken off by a picky instructor....)


$$2\int x\sin ax\cos x dx=\int x\sin(a-1)x dx+\int x\sin(a+1)xdx =I_1+I_2$$ by the formula: $2\sin A\cos B=\sin(A+B)+\sin(A-B)$

Consider $I_1:$ set $u=(a-1)x$, then $du=(a-1)dx$, then

$$\int x\sin(a-1)x dx=\int \frac{u\sin u}{(a-1)^2}du=\frac{1}{(a-1)^2}\int u\sin u du=\underbrace{\cdots}_{\text{integration by parts}}=\frac{1}{(a-1)^2}\big(\sin u- u\cos u\big)$$

Consider now $I_2:$ set $v=(a+1)x$, then $dv=(a+1)dx$, then

$$\int x\sin(a+1)x dx=\int \frac{v\sin v}{(a+1)^2}dv=\frac{1}{(a+1)^2}\int v\sin v dv=\underbrace{\cdots}_{\text{integration by parts}}=\frac{1}{(a+1)^2}\big(\sin v- v\cos v\big)$$

Summing up $I_1+I_2$ we get $$ \frac{1}{(a-1)^2}\big(\sin u- u\cos u\big)+\frac{1}{(a+1)^2}\big(\sin v- v\cos v\big)$$

Finally: $$\int x\sin ax\cos x dx=\frac12\Big[\frac{1}{(a-1)^2}\big(\sin (a-1)x- (a-1)x\cos (a-1)x\big)+ \frac{1}{(a+1)^2}\big(\sin (a+1)x- (a+1)x\cos (a+1)x\big)\Big]$$

  • $\begingroup$ DIfferentiating your result doesn't yield the integrand. I'm not sure how you can sum up $I_{1}$ and $I_{2}$ when they have different arguments. $\endgroup$ – Mattos Apr 20 '18 at 12:38
  • $\begingroup$ I use the same variable for both and I made a mistake! I edit my post, thanks for your comment :) $\endgroup$ – InsideOut Apr 20 '18 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.