Consider the integral
$$ I= \int \frac{ A_0 + A_1\cos{(a_1x)} + A_2\cos{(a_2x)} }{ \big[ B_0 + B_1\cos{(a_1x)} + B_2\cos{(a_2x)} \big]^2 } dx $$
where the constants $A_0,A_1,A_2,B_0,B_1,B_2,a_1,a_2$ are nonzero.
I have been trying to come up with a way to solve the integral without any success. Since the integral originates from an engineering problem, I have worked through an approximate solution that performs fine for the problem, but I was wondering if $I$ can be directly evaluated.
$\textbf{My attempt :}$
One can rewrite the integral as :
$$ \int \frac{ A_0 + A_1\cos{(a_1x)} + A_2\cos{(a_2x)} }{ \big[ B_0 + \delta f(x) \big]^2 } dx $$
With the substitution $\delta f(x) \rightarrow \epsilon \cdot \delta f(x)$, one can expand the fraction with respect to $\epsilon$ in Taylor series up to a desired order. In the expanded quantity, I substitute back
$$ \delta f(x) = B_1\cos{(a_1x)} + B_2\cos{(a_2x)} $$
Then the integral can be evaluated quite easily.
Thank you for your time.
$\textbf{Edit :}$ The constants $a_1$, $a_2$ must not be considered as rationals.
One shouldn't expect a closed-form solution for general values of the parameters, but if $\frac{a_2}{a_1} $ is rational, say, then we can make a change of variable that rationalizes the integrand, whence we can in principle write antiderivative more or less explicitly.
In that case, scaling the variable $x$ of integration by an appropriate factor lets us rewrite the integral as a constant multiple of $$\int \frac{A_0 + A_1 \cos m u + A_2 \cos n u}{(B_0 + B_1 \cos m u + B_2 \cos n u)^2} \,du$$ for some integers $m, n$, or just as well as $$\int \frac{A_0 + A_1 T_m(\cos u) + A_2 T_n(\cos u)}{[B_0 + B_1 T_m(\cos u) + B_2 T_n(\cos u)]^2},$$ where $T_\ell(v)$ denotes the $\ell$th Chebyshev polynomial of the first kind. Applying the tangent half-angle substitution $u = 2 \arctan t$, $du = \frac{2 \,dt}{1 + t^2}$ then transforms the integral to one with a rational integrand, after which the usual techniques for integrating rational functions can be applied: $$\int \frac{A_0' + A_1' T_m\left(\frac{1 - t^2}{1 + t^2}\right) + A_2' T_n\left(\frac{1 - t^2}{1 + t^2}\right)}{\left[B_0' + B_1' T_m\left(\frac{1 - t^2}{1 + t^2}\right) + B_2' T_n\left(\frac{1 - t^2}{1 + t^2}\right)\right]^2 (1 + t^2)} \,dt .$$ But after simplifying the denominator has degree $4 \max\{|m|, |n|\}$, making the function difficult generally unpleasant to integrate for all but the smallest values of $m, n$.
The special case $a_1 = a_2$ (so, $m = n = 1$ in the above) is manageable: By scaling and relabeling may as well write the integral as a constant multiple of $$\int \frac{A_0 + A_1 \cos u}{(B_0' + B_1' \cos u)^2} \,du .$$ The tangent half-angle substitution transforms it to $$2 \int \frac{(A_0 - A_1) t^2 + (A_0 + A_1)}{[(B_0 - B_1) t^2 + (B_0 + B_1)]^2} \,dt,$$ and writing $A_\pm := A_0 \pm A_1$, $B_\pm := B_0 \pm B_1$, (and provided $B_- \neq 0$) decomposing using partial fractions gives $$2 \int \left(\frac{A_-}{B_-} \frac{1}{B_- t^2 + B_+} + \frac{A_+ B_- - A_- B_+}{B_-} \frac{1}{(B_- t^2 + B_+)^2}\right) \,dt .$$ The form of the antiderivative depends on the sign of $\frac{B_+}{B_-}$.