Skip to content

Trigonometric Integrals: Linear and Quadratic Denominators

In our previous discussion of trigonometric integrals, the trigonometric functions appeared primarily in the numerator as integer powers.

A distinctly different challenge arises when trigonometric expressions appear in the denominator, accompanied by constant terms:

\[\int \frac{dx}{a + b\cos x}, \qquad \int \frac{dx}{a\cos x + b\sin x + c}, \qquad \int \frac{dx}{a + b\cos^2 x}\]

Because addition in denominators cannot be split directly, standard algebra fails. Instead, each family of denominators possesses a tailored algebraic bridge that converts the trigonometric function into a polynomial fraction.

In this tutorial, we establish the five fundamental families of linear and quadratic trigonometric denominators.


Pure Linear Combinations via the Auxiliary Angle

We begin with the linear combination without a constant term:

\[\int \frac{dx}{a\cos x + b\sin x}\]

The Method

Any linear combination \(a\cos x + b\sin x\) can be compressed into a single cosine term by introducing an auxiliary angle \(\alpha\):

\[a\cos x + b\sin x = r\left(\frac{a}{r}\cos x + \frac{b}{r}\sin x\right) = r\cos(x - \alpha)\]

where:

\[r = \sqrt{a^2 + b^2}, \qquad \cos\alpha = \frac{a}{\sqrt{a^2 + b^2}}, \qquad \sin\alpha = \frac{b}{\sqrt{a^2 + b^2}} \implies \tan\alpha = \frac{b}{a}\]

Under this transformation, the integral becomes:

\[\int \frac{dx}{a\cos x + b\sin x} = \frac{1}{r}\int \frac{dx}{\cos(x - \alpha)} = \frac{1}{r}\int \sec(x - \alpha)\,dx\]

Using the standard antiderivative of secant:

\[\frac{1}{r}\ln|\sec(x - \alpha) + \tan(x - \alpha)| + C\]

Example 1

Evaluate:

\[I = \int \frac{dx}{\cos x + \sqrt{3}\sin x}\]

Solution:

Here \(a = 1\) and \(b = \sqrt{3}\).

Compute the amplitude \(r\):

\[r = \sqrt{1^2 + (\sqrt{3})^2} = \sqrt{1 + 3} = 2\]

Divide and multiply by \(2\):

\[\cos x + \sqrt{3}\sin x = 2\left( \frac{1}{2}\cos x + \frac{\sqrt{3}}{2}\sin x \right) = 2\left( \cos x \cos\frac{\pi}{3} + \sin x \sin\frac{\pi}{3} \right) = 2\cos\left(x - \frac{\pi}{3}\right)\]

Substitute into the integral:

\[I = \frac{1}{2}\int \frac{dx}{\cos\left(x - \frac{\pi}{3}\right)} = \frac{1}{2}\int \sec\left(x - \frac{\pi}{3}\right)dx\]

Integrating:

\[I = \frac{1}{2}\ln\left| \sec\left(x - \frac{\pi}{3}\right) + \tan\left(x - \frac{\pi}{3}\right) \right| + C\]

Example 2

Evaluate:

\[I = \int \frac{dx}{3\cos x + 4\sin x}\]

Solution:

Here \(a = 3\) and \(b = 4\).

Compute \(r\):

\[r = \sqrt{3^2 + 4^2} = 5\]

Express the denominator as:

\[3\cos x + 4\sin x = 5\cos(x - \alpha) \qquad \text{where } \tan\alpha = \frac{4}{3}\]

The integral becomes:

\[I = \frac{1}{5}\int \sec(x - \alpha)\,dx = \frac{1}{5}\ln|\sec(x - \alpha) + \tan(x - \alpha)| + C\]

Linear Denominators with Constants: The Weierstrass Substitution

When the denominator contains a constant term:

\[\int \frac{dx}{a + b\cos x}, \qquad \int \frac{dx}{a + b\sin x}, \qquad \int \frac{dx}{a\cos x + b\sin x + c}\]

the auxiliary angle method no longer applies because the constant prevents factoring out \(r\).

The universal remedy is the Weierstrass Half-Angle Substitution.

The Half-Angle Dictionary

Let:

\[t = \tan\left(\frac{x}{2}\right)\]

From trigonometry, we express \(\sin x\) and \(\cos x\) as rational functions of \(t\):

\[\cos x = \frac{1 - \tan^2(x/2)}{1 + \tan^2(x/2)} = \frac{1 - t^2}{1 + t^2}\]
\[\sin x = \frac{2\tan(x/2)}{1 + \tan^2(x/2)} = \frac{2t}{1 + t^2}\]

To find the differential \(dx\):

\[x = 2\tan^{-1} t \implies dx = \frac{2\,dt}{1 + t^2}\]

Substituting these three relations into \(\int \frac{dx}{a\cos x + b\sin x + c}\):

\[\int \frac{\frac{2\,dt}{1 + t^2}}{a\left(\frac{1 - t^2}{1 + t^2}\right) + b\left(\frac{2t}{1 + t^2}\right) + c} = \int \frac{2\,dt}{a(1 - t^2) + 2bt + c(1 + t^2)}\]

Collecting powers of \(t\):

\[\int \frac{2\,dt}{(c - a)t^2 + 2bt + (c + a)}\]

This is an ordinary rational quadratic in \(t\), which is evaluated by completing the square using our standard quadratic formulas.


Example 3

Evaluate:

\[I = \int \frac{dx}{5 + 4\cos x}\]

Solution:

Substitute \(t = \tan(x/2)\):

\[dx = \frac{2\,dt}{1 + t^2}, \qquad \cos x = \frac{1 - t^2}{1 + t^2}\]

The denominator simplifies to:

\[5 + 4\left(\frac{1 - t^2}{1 + t^2}\right) = \frac{5(1 + t^2) + 4(1 - t^2)}{1 + t^2} = \frac{t^2 + 9}{1 + t^2}\]

Substitute into the integral:

\[I = \int \frac{\frac{2\,dt}{1 + t^2}}{\frac{t^2 + 9}{1 + t^2}} = \int \frac{2\,dt}{t^2 + 9} = 2\int \frac{dt}{t^2 + 3^2}\]

Using the standard arctangent formula:

\[I = 2 \cdot \frac{1}{3}\tan^{-1}\left(\frac{t}{3}\right) + C = \frac{2}{3}\tan^{-1}\left( \frac{1}{3}\tan\left(\frac{x}{2}\right) \right) + C\]

Example 4

Evaluate:

\[I = \int \frac{dx}{3 + 5\cos x}\]

Solution:

Apply the Weierstrass substitution \(t = \tan(x/2)\):

\[dx = \frac{2\,dt}{1 + t^2}, \qquad \cos x = \frac{1 - t^2}{1 + t^2}\]

Transform the denominator:

\[3 + 5\left(\frac{1 - t^2}{1 + t^2}\right) = \frac{3(1 + t^2) + 5(1 - t^2)}{1 + t^2} = \frac{8 - 2t^2}{1 + t^2} = \frac{2(4 - t^2)}{1 + t^2}\]

Substitute into the integral:

\[I = \int \frac{\frac{2\,dt}{1 + t^2}}{\frac{2(4 - t^2)}{1 + t^2}} = \int \frac{dt}{4 - t^2} = \int \frac{dt}{2^2 - t^2}\]

Using the standard difference-of-squares formula:

\[I = \frac{1}{2(2)}\ln\left| \frac{2 + t}{2 - t} \right| + C = \frac{1}{4}\ln\left| \frac{2 + \tan(x/2)}{2 - \tan(x/2)} \right| + C\]

Notice the contrast with Example 3: when the constant term exceeds the cosine coefficient (\(5 > 4\)), the quadratic denominator has complex roots and yields an arctangent. When the cosine coefficient exceeds the constant (\(5 > 3\)), the quadratic denominator factors into real roots and yields a logarithm.


Example 5

Evaluate:

\[I = \int \frac{dx}{1 + \sin x + \cos x}\]

Solution:

Substitute \(t = \tan(x/2)\):

\[dx = \frac{2\,dt}{1 + t^2}, \qquad \sin x = \frac{2t}{1 + t^2}, \qquad \cos x = \frac{1 - t^2}{1 + t^2}\]

Combine the terms in the denominator:

\[1 + \sin x + \cos x = \frac{(1 + t^2) + 2t + (1 - t^2)}{1 + t^2} = \frac{2 + 2t}{1 + t^2} = \frac{2(1 + t)}{1 + t^2}\]

Substitute into the integral:

\[I = \int \frac{\frac{2\,dt}{1 + t^2}}{\frac{2(1 + t)}{1 + t^2}} = \int \frac{dt}{1 + t} = \ln|1 + t| + C\]

Returning to \(x\):

\[I = \ln\left| 1 + \tan\left(\frac{x}{2}\right) \right| + C\]

Example 6

Evaluate:

\[I = \int \frac{dx}{2 + \sin x}\]

Solution:

Substitute \(t = \tan(x/2)\):

\[2 + \sin x = 2 + \frac{2t}{1 + t^2} = \frac{2(1 + t^2) + 2t}{1 + t^2} = \frac{2(t^2 + t + 1)}{1 + t^2}\]

Substitute into the integral:

\[I = \int \frac{\frac{2\,dt}{1 + t^2}}{\frac{2(t^2 + t + 1)}{1 + t^2}} = \int \frac{dt}{t^2 + t + 1}\]

Complete the square in the quadratic denominator:

\[t^2 + t + 1 = \left(t + \frac{1}{2}\right)^2 + \frac{3}{4} = \left(t + \frac{1}{2}\right)^2 + \left(\frac{\sqrt{3}}{2}\right)^2\]

Using the arctangent formula:

\[I = \frac{1}{\sqrt{3}/2}\tan^{-1}\left( \frac{t + 1/2}{\sqrt{3}/2} \right) + C = \frac{2}{\sqrt{3}}\tan^{-1}\left( \frac{2t + 1}{\sqrt{3}} \right) + C\]

Substitute \(t = \tan(x/2)\):

\[I = \frac{2}{\sqrt{3}}\tan^{-1}\left( \frac{2\tan(x/2) + 1}{\sqrt{3}} \right) + C\]

Example 7

Evaluate:

\[I = \int \frac{dx}{1 + \cos x}\]

Solution:

While the Weierstrass substitution works, applying half-angle identities directly avoids intermediate rational fractions.

Recall:

\[1 + \cos x = 2\cos^2\left(\frac{x}{2}\right)\]

Substitute directly into the integral:

\[I = \int \frac{dx}{2\cos^2(x/2)} = \frac{1}{2}\int \sec^2\left(\frac{x}{2}\right)dx = \frac{1}{2} \cdot \frac{\tan(x/2)}{1/2} + C = \tan\left(\frac{x}{2}\right) + C\]

Linear Numerator Over Linear Denominator

When linear trigonometric expressions appear in both the numerator and the denominator:

\[\int \frac{p\cos x + q\sin x}{a\cos x + b\sin x}\,dx \qquad \text{or} \qquad \int \frac{p\cos x + q\sin x + r}{a\cos x + b\sin x + c}\,dx\]

the standard strategy is to express the numerator as a linear combination of the denominator and its derivative.

The Algebraic Decomposition

Write:

\[\text{Numerator} = A(\text{Denominator}) + B\left(\frac{d}{dx}(\text{Denominator})\right) + C\]

Equating coefficients of \(\sin x\), \(\cos x\), and the constant term produces a system of linear equations for the constants \(A\), \(B\), and \(C\).

Substituting this decomposition into the integral splits it into three simple parts:

\[I = A \int 1\,dx + B \int \frac{\text{Denominator}'}{\text{Denominator}}\,dx + C \int \frac{dx}{\text{Denominator}}\]
\[I = Ax + B\ln|\text{Denominator}| + C \int \frac{dx}{\text{Denominator}}\]

The third integral is evaluated using the Weierstrass half-angle substitution.


Example 8

Evaluate:

\[I = \int \frac{3\sin x + 2\cos x}{2\sin x + 3\cos x}\,dx\]

Solution:

Set up the decomposition without a constant (since no constant appears in the integrand):

\[\text{Numerator} = A(\text{Denominator}) + B\left(\frac{d}{dx}(\text{Denominator})\right)\]

Compute the derivative of the denominator:

\[\frac{d}{dx}(2\sin x + 3\cos x) = 2\cos x - 3\sin x\]

Write the identity:

\[3\sin x + 2\cos x = A(2\sin x + 3\cos x) + B(2\cos x - 3\sin x)\]
\[3\sin x + 2\cos x = (2A - 3B)\sin x + (3A + 2B)\cos x\]

Equate corresponding coefficients:

\[2A - 3B = 3\]
\[3A + 2B = 2\]

Multiply the first equation by \(2\) and the second by \(3\):

\[4A - 6B = 6\]
\[9A + 6B = 6\]

Adding both equations:

\[13A = 12 \implies A = \frac{12}{13}\]

Substitute into the first equation:

\[2\left(\frac{12}{13}\right) - 3B = 3 \implies 3B = \frac{24}{13} - 3 = -\frac{15}{13} \implies B = -\frac{5}{13}\]

Now split the integral:

\[I = \frac{12}{13}\int 1\,dx - \frac{5}{13}\int \frac{2\cos x - 3\sin x}{2\sin x + 3\cos x}\,dx\]
\[I = \frac{12}{13}x - \frac{5}{13}\ln|2\sin x + 3\cos x| + C\]

Example 9

Evaluate:

\[I = \int \frac{2\sin x + \cos x + 3}{\sin x + 2\cos x + 1}\,dx\]

Solution:

Set up the decomposition:

\[\text{Numerator} = A(\text{Denominator}) + B\left(\frac{d}{dx}(\text{Denominator})\right) + C\]
\[2\sin x + \cos x + 3 = A(\sin x + 2\cos x + 1) + B(\cos x - 2\sin x) + C\]

Collect like terms:

\[2\sin x + \cos x + 3 = (A - 2B)\sin x + (2A + B)\cos x + (A + C)\]

Equate coefficients:

\[A - 2B = 2\]
\[2A + B = 1\]
\[A + C = 3\]

From the second equation, \(B = 1 - 2A\). Substitute into the first:

\[A - 2(1 - 2A) = 2 \implies 5A - 2 = 2 \implies 5A = 4 \implies A = \frac{4}{5}\]
\[B = 1 - 2\left(\frac{4}{5}\right) = -\frac{3}{5}\]
\[C = 3 - \frac{4}{5} = \frac{11}{5}\]

The integral splits into three parts:

\[I = \frac{4}{5}\int 1\,dx - \frac{3}{5}\int \frac{\cos x - 2\sin x}{\sin x + 2\cos x + 1}\,dx + \frac{11}{5}\int \frac{dx}{\sin x + 2\cos x + 1}\]
\[I = \frac{4}{5}x - \frac{3}{5}\ln|\sin x + 2\cos x + 1| + \frac{11}{5} I_1\]

To evaluate \(I_1 = \int \frac{dx}{\sin x + 2\cos x + 1}\), use the Weierstrass substitution \(t = \tan(x/2)\):

\[\sin x + 2\cos x + 1 = \frac{2t + 2(1 - t^2) + (1 + t^2)}{1 + t^2} = \frac{3 + 2t - t^2}{1 + t^2}\]
\[I_1 = \int \frac{\frac{2\,dt}{1 + t^2}}{\frac{3 + 2t - t^2}{1 + t^2}} = \int \frac{2\,dt}{3 + 2t - t^2} = 2\int \frac{dt}{4 - (t - 1)^2} = 2 \cdot \frac{1}{2(2)}\ln\left| \frac{2 + (t - 1)}{2 - (t - 1)} \right| = \frac{1}{2}\ln\left| \frac{t + 1}{3 - t} \right|\]

Substitute \(t = \tan(x/2)\) and combine into \(I\):

\[I = \frac{4}{5}x - \frac{3}{5}\ln|\sin x + 2\cos x + 1| + \frac{11}{10}\ln\left| \frac{\tan(x/2) + 1}{3 - \tan(x/2)} \right| + C\]

Quadratic Denominators with Even Powers

When the denominator contains even powers of sine and cosine:

\[\int \frac{dx}{a + b\cos^2 x}, \qquad \int \frac{dx}{a + b\sin^2 x}, \qquad \int \frac{dx}{a\cos^2 x + b\sin x\cos x + c\sin^2 x}, \qquad \int \frac{dx}{(a\sin x + b\cos x)^2}\]

the half-angle substitution \(t = \tan(x/2)\) would create a fourth-degree polynomial, which is needlessly difficult.

Instead, we use the Tangent Substitution:

\[t = \tan x \implies dt = \sec^2 x\,dx\]

The Standard Procedure

  1. Divide both the numerator and the denominator by \(\cos^2 x\).
  2. The numerator becomes \(\frac{dx}{\cos^2 x} = \sec^2 x\,dx\), which provides the differential \(dt\).
  3. In the denominator, any constant term \(k\) becomes \(k\sec^2 x = k(1 + \tan^2 x)\).
  4. The integral reduces to a standard quadratic rational form \(\int \frac{dt}{At^2 + Bt + C}\).

Example 10

Evaluate:

\[I = \int \frac{dx}{1 + 3\cos^2 x}\]

Solution:

Divide numerator and denominator by \(\cos^2 x\):

\[I = \int \frac{\sec^2 x\,dx}{\sec^2 x + 3}\]

Replace \(\sec^2 x\) in the denominator with \(1 + \tan^2 x\):

\[I = \int \frac{\sec^2 x\,dx}{(1 + \tan^2 x) + 3} = \int \frac{\sec^2 x\,dx}{\tan^2 x + 4}\]

Let:

\[t = \tan x \implies dt = \sec^2 x\,dx\]

Substitute into the integral:

\[I = \int \frac{dt}{t^2 + 2^2} = \frac{1}{2}\tan^{-1}\left(\frac{t}{2}\right) + C\]

Returning to \(x\):

\[I = \frac{1}{2}\tan^{-1}\left(\frac{\tan x}{2}\right) + C\]

Example 11

Evaluate:

\[I = \int \frac{dx}{2\sin^2 x + 3\cos^2 x}\]

Solution:

Divide numerator and denominator by \(\cos^2 x\):

\[I = \int \frac{\sec^2 x\,dx}{2\tan^2 x + 3} = \frac{1}{2}\int \frac{\sec^2 x\,dx}{\tan^2 x + \frac{3}{2}}\]

Let \(t = \tan x \implies dt = \sec^2 x\,dx\):

\[I = \frac{1}{2}\int \frac{dt}{t^2 + \left(\sqrt{\frac{3}{2}}\right)^2} = \frac{1}{2} \cdot \frac{1}{\sqrt{3/2}}\tan^{-1}\left( \frac{t}{\sqrt{3/2}} \right) + C\]

Simplify the leading coefficient:

\[\frac{1}{2} \cdot \frac{\sqrt{2}}{\sqrt{3}} = \frac{1}{\sqrt{2}\sqrt{3}} = \frac{1}{\sqrt{6}}\]

Therefore:

\[I = \frac{1}{\sqrt{6}}\tan^{-1}\left( \frac{\sqrt{2}\tan x}{\sqrt{3}} \right) + C\]

Example 12

Evaluate:

\[I = \int \frac{dx}{1 + 3\sin^2 x + 8\cos^2 x}\]

Solution:

Divide numerator and denominator by \(\cos^2 x\):

\[I = \int \frac{\sec^2 x\,dx}{\sec^2 x + 3\tan^2 x + 8}\]

Replace \(\sec^2 x\) with \(1 + \tan^2 x\):

\[I = \int \frac{\sec^2 x\,dx}{(1 + \tan^2 x) + 3\tan^2 x + 8} = \int \frac{\sec^2 x\,dx}{4\tan^2 x + 9}\]

Let \(t = \tan x \implies dt = \sec^2 x\,dx\):

\[I = \int \frac{dt}{4t^2 + 9} = \frac{1}{4}\int \frac{dt}{t^2 + \left(\frac{3}{2}\right)^2}\]

Using the arctangent formula:

\[I = \frac{1}{4} \cdot \frac{1}{3/2}\tan^{-1}\left( \frac{t}{3/2} \right) + C = \frac{1}{6}\tan^{-1}\left( \frac{2\tan x}{3} \right) + C\]

Example 13

Evaluate:

\[I = \int \frac{dx}{(2\sin x + 3\cos x)^2}\]

Solution:

Divide numerator and denominator by \(\cos^2 x\):

\[I = \int \frac{\sec^2 x\,dx}{(2\tan x + 3)^2}\]

Let:

\[t = 2\tan x + 3 \implies dt = 2\sec^2 x\,dx \implies \sec^2 x\,dx = \frac{dt}{2}\]

Substitute into the integral:

\[I = \int \frac{\frac{dt}{2}}{t^2} = \frac{1}{2}\int t^{-2}\,dt = -\frac{1}{2t} + C\]

Substitute \(t = 2\tan x + 3\):

\[I = -\frac{1}{2(2\tan x + 3)} + C\]

Shifted Angle Differences in Denominators

A classic class of problems features products of sines or cosines with shifted phase arguments in the denominator:

\[\int \frac{dx}{\sin(x - a)\sin(x - b)}, \qquad \int \frac{dx}{\cos(x - a)\cos(x - b)}, \qquad \int \frac{dx}{\sin(x - a)\cos(x - b)}\]

The Algebraic Artifice

Notice that the difference between the two angles is independent of the variable \(x\):

\[(x - a) - (x - b) = b - a \qquad \text{or} \qquad (x - b) - (x - a) = a - b\]

We multiply and divide the integral by the constant trigonometric term \(\sin(a - b)\) or \(\cos(a - b)\):

  1. When both factors are of the same kind (both sines or both cosines), multiply and divide by \(\sin(a - b)\).
  2. When the factors are of different kinds (one sine and one cosine), multiply and divide by \(\cos(a - b)\).

Expanding the numerator using addition formulas cancels one factor in each term, converting the integrand into basic tangents and cotangents.


Example 14

Evaluate:

\[I = \int \frac{dx}{\sin(x - a)\sin(x - b)}\]

Solution:

Multiply and divide by \(\sin(a - b)\):

\[I = \frac{1}{\sin(a - b)}\int \frac{\sin(a - b)}{\sin(x - a)\sin(x - b)}\,dx\]

Rewrite \(a - b\) as \((x - b) - (x - a)\):

\[\sin(a - b) = \sin[(x - b) - (x - a)] = \sin(x - b)\cos(x - a) - \cos(x - b)\sin(x - a)\]

Divide through by the denominator:

\[\frac{\sin(a - b)}{\sin(x - a)\sin(x - b)} = \frac{\sin(x - b)\cos(x - a)}{\sin(x - a)\sin(x - b)} - \frac{\cos(x - b)\sin(x - a)}{\sin(x - a)\sin(x - b)}\]
\[\frac{\sin(a - b)}{\sin(x - a)\sin(x - b)} = \cot(x - a) - \cot(x - b)\]

Integrate directly:

\[I = \frac{1}{\sin(a - b)}\int [\cot(x - a) - \cot(x - b)]dx\]
\[I = \frac{1}{\sin(a - b)}\left( \ln|\sin(x - a)| - \ln|\sin(x - b)| \right) + C\]

Applying the logarithm quotient rule:

\[I = \frac{1}{\sin(a - b)}\ln\left| \frac{\sin(x - a)}{\sin(x - b)} \right| + C\]

Example 15

Evaluate:

\[I = \int \frac{dx}{\cos(x - a)\cos(x - b)}\]

Solution:

Both factors are cosines (same kind), so multiply and divide by \(\sin(a - b)\):

\[I = \frac{1}{\sin(a - b)}\int \frac{\sin[(x - b) - (x - a)]}{\cos(x - a)\cos(x - b)}\,dx\]

Expand the numerator:

\[\sin[(x - b) - (x - a)] = \sin(x - b)\cos(x - a) - \cos(x - b)\sin(x - a)\]

Divide by the denominator:

\[\frac{\sin(x - b)\cos(x - a)}{\cos(x - a)\cos(x - b)} - \frac{\cos(x - b)\sin(x - a)}{\cos(x - a)\cos(x - b)} = \tan(x - b) - \tan(x - a)\]

Substitute into the integral:

\[I = \frac{1}{\sin(a - b)}\int [\tan(x - b) - \tan(x - a)]dx\]

Recall that \(\int \tan u\,du = -\ln|\cos u|\):

\[I = \frac{1}{\sin(a - b)}\left( -\ln|\cos(x - b)| + \ln|\cos(x - a)| \right) + C\]
\[I = \frac{1}{\sin(a - b)}\ln\left| \frac{\cos(x - a)}{\cos(x - b)} \right| + C\]

Example 16

Evaluate:

\[I = \int \frac{dx}{\sin(x - a)\cos(x - b)}\]

Solution:

Here the factors in the denominator are mixed (one sine and one cosine). Multiply and divide by \(\cos(a - b)\):

\[I = \frac{1}{\cos(a - b)}\int \frac{\cos[(x - a) - (x - b)]}{\sin(x - a)\cos(x - b)}\,dx\]

Expand using the cosine subtraction formula \(\cos(A - B) = \cos A\cos B + \sin A\sin B\):

\[\cos[(x - a) - (x - b)] = \cos(x - a)\cos(x - b) + \sin(x - a)\sin(x - b)\]

Divide through by the denominator:

\[\frac{\cos(x - a)\cos(x - b)}{\sin(x - a)\cos(x - b)} + \frac{\sin(x - a)\sin(x - b)}{\sin(x - a)\cos(x - b)} = \cot(x - a) + \tan(x - b)\]

Substitute into the integral:

\[I = \frac{1}{\cos(a - b)}\int [\cot(x - a) + \tan(x - b)]dx\]

Integrating:

\[I = \frac{1}{\cos(a - b)}\left( \ln|\sin(x - a)| - \ln|\cos(x - b)| \right) + C\]

Combining the logarithms:

\[I = \frac{1}{\cos(a - b)}\ln\left| \frac{\sin(x - a)}{\cos(x - b)} \right| + C\]