Why do we multiply numerator and denominator by $\sin px$ for evaluating $\int \frac{\cos ax+\cos bx}{1-2\cos cx}dx$? I got this question on seeing the solution for evaluating the integral $\int \frac{\cos 5x+\cos 4x}{1-2\cos 3x}dx$ in my textbook. I searched this site, and found the following questions:


*

*Another way to evaluate $\int\frac{\cos5x+\cos4x}{1-2\cos3x}{dx}$? (Exactly the same integral)

*How to integrate $\frac {\cos (7x)-\cos (8x)}{1+2\cos (5x)} $ ?
In both of these questions and in my book, the first step involves multiplying the numerator and the denominator by $\sin px$ where $p=3$ in the first integral and $p=5$ in the second integral.
I wondered, why we must multiply both numerator and denominator by sine of "something" and how to determine that "something"? I was unable to answer the first question. But I was able to make some progress in solving the second question which I've discussed below:
Let us consider the following integral where $a,b,$ and $c$ are constants,
$$\int \frac{\cos ax+\cos bx}{1-2\cos cx}dx$$
In order to evaluate this integral we need to multiply both numerator and denominator by $\sin px$ where $p$ is some constant which we need to figure out. I guessed two possibilities:


*

*$p=c$

*$p=\frac{(a+b)}{3}$
Unfortunately, I was unable to tell which of the above two possibilities is the reason for the choice of $p$, because in both integrals (linked questions) the above two conditions are satisfied simultaneously.
In short, I'm confused why most of the sources multiply $\sin px$ in both numerator and denominator to solve this kind of integral. Is this some kind of a general rule or totally a guess? What are the constrains for the variable $p$ in $\sin px$? Or how do we determine $p$ in case of any integral of this form? Or is that also a guess?
Kindly explain the above two questions. 
Thank you in advance.
 A: In the integral $\int \dfrac{\cos 5x+\cos 4x}{1-2\cos 3x}dx$ , the numbers $5$, $4$ and 
$3$ are very carefully chosen such that the integrand can be simplified. It is not possible to solve the integral with any $a$, $b$ and $c$ ; instead of some specific carefully choosen $a$, $b$ and $c$.
Now,  $$\int \dfrac{\cos 5x+\cos 4x}{1-2\cos 3x}dx = \int \dfrac{(\sin 3x)(\cos 5x+\cos 4x)}{(\sin 3x)(1-2\cos 3x)}dx$$ 
I have multiplied numerator and denominator by $\sin 3x$ to remove the coefficient "2" of $\cos 3x$ since $2\sin 3x\cos 3x$ would yield $\sin 6x$ (in general, $p$ should be equal to $c$ to remove that "2"). I am removing this "2" to apply the formula of $\sin A - \sin B$, in the hope that, doing similar thing (i.e. applying formula of $\cos A +  \cos B$) in numerator would lead to cancellation of some common terms from numerator and denominator (that's exactly what will happen if you notice the solution further).
The cancellation is because of the choice of appropriate angles ($5x,4x$ and $3x$) of sine and cosine. This cancellation would not be possible if the angles are randomly chosen. What I mean to say is that besides having $p$ to be equal to $c$ , $a$ and $b$ should be well chosen so that the integrand can be simplified. 
$$\int \dfrac{\cos 5x+\cos 4x}{1-2\cos 3x}dx= \int \dfrac{(\sin 3x)(\cos 5x+\cos 4x)}{\sin 3x-2\sin 3x.\cos 3x}dx$$
$$= \int \dfrac{(\sin 3x)(\cos 5x+\cos 4x)}{\sin 3x-\sin 6x}dx$$ 
$$= \int \dfrac{(\sin 3x)(\cos 5x+\cos 4x)}{2\cos \frac{9x}{2}.\sin\frac{-3x}{2}}dx$$
$$= \int \dfrac{(\sin 3x)(\require{cancel}\cancel{2} \cancel{\cos \frac{9x}{2}}.\cos \frac {x}{2})}{\cancel{2}\cancel{\cos \frac{9x}{2}}.\sin\frac{-3x}{2}}dx$$
$$= \int \dfrac{(2\cancel{\sin \frac{3x}{2}}.\cos \frac{3x}{2})(\cos \frac{x}{2})}{(-\cancel{\sin \frac{3x}{2}})}dx$$
$$= -\int (2\cos \frac{3x}{2}.\cos \frac{x}{2})dx$$
$$= -\int (\cos 2x+\cos x)dx$$
$$= \int (-\cos 2x-\cos x)dx$$
$$= -\dfrac {\sin 2x}{2} - \sin x + c$$
