2.3 Problem number 250

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

Optimal antiderivative \[ -\frac {\arctanh \! \left (\frac {a \cos \left (x \right )-b \sin \left (x \right )}{\sqrt {a^{2}+b^{2}}}\right )}{\sqrt {a^{2}+b^{2}}} \]

command

integrate(1/(b*cos(x)+a*sin(x)),x)

Sympy 1.10.1 under Python 3.10.4 output

\[ \text {Exception raised: AttributeError} \]

Sympy 1.8 under Python 3.8.8 output

\[ \begin {cases} \tilde {\infty } \left (- \log {\left (\tan {\left (\frac {x}{2} \right )} - 1 \right )} + \log {\left (\tan {\left (\frac {x}{2} \right )} + 1 \right )}\right ) & \text {for}\: a = 0 \wedge b = 0 \\\frac {\log {\left (\tan {\left (\frac {x}{2} \right )} \right )}}{a} & \text {for}\: b = 0 \\\frac {1}{b \sin {\left (x \right )} + i \sqrt {b^{2}} \cos {\left (x \right )}} & \text {for}\: a = - \sqrt {- b^{2}} \\\frac {1}{b \sin {\left (x \right )} - i \sqrt {b^{2}} \cos {\left (x \right )}} & \text {for}\: a = \sqrt {- b^{2}} \\- \frac {\log {\left (- \frac {a}{b} + \tan {\left (\frac {x}{2} \right )} - \frac {\sqrt {a^{2} + b^{2}}}{b} \right )}}{\sqrt {a^{2} + b^{2}}} + \frac {\log {\left (- \frac {a}{b} + \tan {\left (\frac {x}{2} \right )} + \frac {\sqrt {a^{2} + b^{2}}}{b} \right )}}{\sqrt {a^{2} + b^{2}}} & \text {otherwise} \end {cases} \]