Multiply top and bottom by cos(x):
dx/(bcos(x)+asin(x)).
Let a=rcosθ and b=rsinθ, r=√(a²+b²), then the integrand becomes:
(1/r)cosec(θ+x)dx.
Multiply top and bottom by cosec(θ+x)+cot(θ+x):
(1/r)(cosec²(θ+x)+cot(θ+x)cosec(θ+x))dx/(cosec(θ+x)+cot(θ+x)).
For general angle A the derivative of cosecA=-cotAcosecA and of cotA it’s -cosec²A, so the trig part of the numerator is the negative derivative of the denominator, so integrating we get:
-(1/r)ln|cosec(θ+x)+cot(θ+x)|+C, where C is the integration constant which can be incorporated into the log as a different constant c:
(1/r)ln(c/(cosec(θ+x)+cot(θ+x)).
cosec(θ+x)+cot(θ+x)=(1+cos(θ+x))/sin(θ+x), so the inverse is:
sin(θ+x)/(1+cos(θ+x))=
((b/r)cos(x)+(a/r)sin(x))/(1+(a/r)cos(x)-(b/r)sin(x)).
The result of integration is:
(1/√(a²+b²))ln[c(b+atan(x))/(sec(x)√(a²+b²)+a-btan(x))].