Primitive of Reciprocal of Sine of a x minus Cosine of a x

Theorem

 * $\displaystyle \int \frac {\mathrm d x} {\sin a x - \cos a x} = \frac 1 {a \sqrt 2} \ln \left\vert{\tan \left({\frac {a x} 2 - \frac \pi 8}\right)}\right\vert + C$

Proof
Let:

Also see

 * Primitive of $\dfrac 1 {\sin a x + \cos a x}$