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

Optimal. Leaf size=36 \[ -\frac {\tanh ^{-1}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{\sqrt {a^2+b^2}} \]

[Out]

-arctanh((a*cos(x)-b*sin(x))/(a^2+b^2)^(1/2))/(a^2+b^2)^(1/2)

________________________________________________________________________________________

Rubi [A]
time = 0.01, antiderivative size = 36, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 2, integrand size = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.182, Rules used = {3153, 212} \begin {gather*} -\frac {\tanh ^{-1}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{\sqrt {a^2+b^2}} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(b*Cos[x] + a*Sin[x])^(-1),x]

[Out]

-(ArcTanh[(a*Cos[x] - b*Sin[x])/Sqrt[a^2 + b^2]]/Sqrt[a^2 + b^2])

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 3153

Int[(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Dist[-d^(-1), Subst[Int
[1/(a^2 + b^2 - x^2), x], x, b*Cos[c + d*x] - a*Sin[c + d*x]], x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2,
0]

Rubi steps

\begin {align*} \int \frac {1}{b \cos (x)+a \sin (x)} \, dx &=-\text {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,a \cos (x)-b \sin (x)\right )\\ &=-\frac {\tanh ^{-1}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{\sqrt {a^2+b^2}}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.03, size = 38, normalized size = 1.06 \begin {gather*} \frac {2 \tanh ^{-1}\left (\frac {-a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\sqrt {a^2+b^2}} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(b*Cos[x] + a*Sin[x])^(-1),x]

[Out]

(2*ArcTanh[(-a + b*Tan[x/2])/Sqrt[a^2 + b^2]])/Sqrt[a^2 + b^2]

________________________________________________________________________________________

Mathics [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {cought exception: maximum recursion depth exceeded} \end {gather*}

Warning: Unable to verify antiderivative.

[In]

mathics('Integrate[1/(b*Cos[x] + a*Sin[x]),x]')

[Out]

cought exception: maximum recursion depth exceeded

________________________________________________________________________________________

Maple [A]
time = 0.09, size = 35, normalized size = 0.97

method result size
default \(-\frac {2 \arctanh \left (\frac {-2 b \tan \left (\frac {x}{2}\right )+2 a}{2 \sqrt {a^{2}+b^{2}}}\right )}{\sqrt {a^{2}+b^{2}}}\) \(35\)
risch \(\frac {\ln \left ({\mathrm e}^{i x}+\frac {i b -a}{\sqrt {a^{2}+b^{2}}}\right )}{\sqrt {a^{2}+b^{2}}}-\frac {\ln \left ({\mathrm e}^{i x}-\frac {i b -a}{\sqrt {a^{2}+b^{2}}}\right )}{\sqrt {a^{2}+b^{2}}}\) \(74\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(1/(b*cos(x)+a*sin(x)),x,method=_RETURNVERBOSE)

[Out]

-2/(a^2+b^2)^(1/2)*arctanh(1/2*(-2*b*tan(1/2*x)+2*a)/(a^2+b^2)^(1/2))

________________________________________________________________________________________

Maxima [A]
time = 0.35, size = 61, normalized size = 1.69 \begin {gather*} -\frac {\log \left (\frac {a - \frac {b \sin \left (x\right )}{\cos \left (x\right ) + 1} + \sqrt {a^{2} + b^{2}}}{a - \frac {b \sin \left (x\right )}{\cos \left (x\right ) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{\sqrt {a^{2} + b^{2}}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(b*cos(x)+a*sin(x)),x, algorithm="maxima")

[Out]

-log((a - b*sin(x)/(cos(x) + 1) + sqrt(a^2 + b^2))/(a - b*sin(x)/(cos(x) + 1) - sqrt(a^2 + b^2)))/sqrt(a^2 + b
^2)

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 98 vs. \(2 (32) = 64\).
time = 0.34, size = 98, normalized size = 2.72 \begin {gather*} \frac {\log \left (-\frac {2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - a^{2} - 2 \, b^{2} + 2 \, \sqrt {a^{2} + b^{2}} {\left (a \cos \left (x\right ) - b \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + a^{2}}\right )}{2 \, \sqrt {a^{2} + b^{2}}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(1/(b*cos(x)+a*sin(x)),x, algorithm="fricas")

[Out]

1/2*log(-(2*a*b*cos(x)*sin(x) - (a^2 - b^2)*cos(x)^2 - a^2 - 2*b^2 + 2*sqrt(a^2 + b^2)*(a*cos(x) - b*sin(x)))/
(2*a*b*cos(x)*sin(x) - (a^2 - b^2)*cos(x)^2 + a^2))/sqrt(a^2 + b^2)

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {1}{a \sin {\left (x \right )} + b \cos {\left (x \right )}}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Giac [A]
time = 0.01, size = 75, normalized size = 2.08 \begin {gather*} -\frac {2 \ln \left (\frac {\left |2 \tan \left (\frac {x}{2}\right ) b-2 a-2 \sqrt {a^{2}+b^{2}}\right |}{\left |2 \tan \left (\frac {x}{2}\right ) b-2 a+2 \sqrt {a^{2}+b^{2}}\right |}\right )}{2 \sqrt {a^{2}+b^{2}}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-log(abs(2*b*tan(1/2*x) - 2*a - 2*sqrt(a^2 + b^2))/abs(2*b*tan(1/2*x) - 2*a + 2*sqrt(a^2 + b^2)))/sqrt(a^2 + b
^2)

________________________________________________________________________________________

Mupad [B]
time = 0.73, size = 31, normalized size = 0.86 \begin {gather*} -\frac {2\,\mathrm {atanh}\left (\frac {a-b\,\mathrm {tan}\left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\sqrt {a^2+b^2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-(2*atanh((a - b*tan(x/2))/(a^2 + b^2)^(1/2)))/(a^2 + b^2)^(1/2)

________________________________________________________________________________________