How to compute the following integral \begin{equation} \int_0^\pi\frac{\cos nx}{a^2-2ab\cos x+b^2}\, dx \end{equation}
I have been given two integral questions by my teacher. I cannot answer this one. I have also searched the similar question here but it looks like nothing is similar so I think this is not a duplicate. I could compute the integral if \begin{equation} \int_0^\pi\frac{dx}{a^2-2ab\cos x+b^2} \end{equation} The $\cos nx$ part makes the integral is really difficult. I want to use the result to compute this integral (the real question given by my teacher) \begin{equation} \int_0^\pi\frac{x^2\cos nx}{a^2-2ab\cos x+b^2}\, dx \end{equation} My question is how to compute the first integral (in the grey-shaded part) preferably with elementary ways (high school methods)?