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

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 11, antiderivative size = 17 \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=\frac {\sin (x)}{b (b \cos (x)+a \sin (x))} \]

[Out]

sin(x)/b/(b*cos(x)+a*sin(x))

Rubi [A] (verified)

Time = 0.01 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.00, number of steps used = 1, number of rules used = 1, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.091, Rules used = {3154} \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=\frac {\sin (x)}{b (a \sin (x)+b \cos (x))} \]

[In]

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

[Out]

Sin[x]/(b*(b*Cos[x] + a*Sin[x]))

Rule 3154

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

Rubi steps \begin{align*} \text {integral}& = \frac {\sin (x)}{b (b \cos (x)+a \sin (x))} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.03 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.00 \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=\frac {\sin (x)}{b (b \cos (x)+a \sin (x))} \]

[In]

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

[Out]

Sin[x]/(b*(b*Cos[x] + a*Sin[x]))

Maple [A] (verified)

Time = 0.30 (sec) , antiderivative size = 14, normalized size of antiderivative = 0.82

method result size
default \(-\frac {1}{a \left (a \tan \left (x \right )+b \right )}\) \(14\)
parallelrisch \(\frac {\sin \left (x \right )}{b \left (b \cos \left (x \right )+a \sin \left (x \right )\right )}\) \(18\)
norman \(\frac {-\frac {1}{a}+\frac {\tan ^{2}\left (\frac {x}{2}\right )}{a}}{-b \left (\tan ^{2}\left (\frac {x}{2}\right )\right )+2 a \tan \left (\frac {x}{2}\right )+b}\) \(38\)
risch \(-\frac {2 i}{\left (a \,{\mathrm e}^{2 i x}+i b \,{\mathrm e}^{2 i x}-a +i b \right ) \left (i b +a \right )}\) \(38\)

[In]

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

[Out]

-1/a/(a*tan(x)+b)

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 39 vs. \(2 (17) = 34\).

Time = 0.26 (sec) , antiderivative size = 39, normalized size of antiderivative = 2.29 \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=-\frac {a \cos \left (x\right ) - b \sin \left (x\right )}{{\left (a^{2} b + b^{3}\right )} \cos \left (x\right ) + {\left (a^{3} + a b^{2}\right )} \sin \left (x\right )} \]

[In]

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

[Out]

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

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 602 vs. \(2 (14) = 28\).

Time = 134.57 (sec) , antiderivative size = 602, normalized size of antiderivative = 35.41 \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=\begin {cases} \frac {\tilde {\infty } \tan {\left (\frac {x}{2} \right )}}{\tan ^{2}{\left (\frac {x}{2} \right )} - 1} & \text {for}\: a = 0 \wedge b = 0 \\\frac {x \tan ^{4}{\left (\frac {x}{2} \right )}}{2 b^{2} \sin ^{2}{\left (x \right )} \tan ^{4}{\left (\frac {x}{2} \right )} - 4 b^{2} \sin ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )} + 2 b^{2} \sin ^{2}{\left (x \right )} + 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan ^{3}{\left (\frac {x}{2} \right )} - 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan {\left (\frac {x}{2} \right )} + 8 b^{2} \cos ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )}} + \frac {2 x \tan ^{2}{\left (\frac {x}{2} \right )}}{2 b^{2} \sin ^{2}{\left (x \right )} \tan ^{4}{\left (\frac {x}{2} \right )} - 4 b^{2} \sin ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )} + 2 b^{2} \sin ^{2}{\left (x \right )} + 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan ^{3}{\left (\frac {x}{2} \right )} - 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan {\left (\frac {x}{2} \right )} + 8 b^{2} \cos ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )}} + \frac {x}{2 b^{2} \sin ^{2}{\left (x \right )} \tan ^{4}{\left (\frac {x}{2} \right )} - 4 b^{2} \sin ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )} + 2 b^{2} \sin ^{2}{\left (x \right )} + 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan ^{3}{\left (\frac {x}{2} \right )} - 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan {\left (\frac {x}{2} \right )} + 8 b^{2} \cos ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )}} + \frac {2 \tan ^{3}{\left (\frac {x}{2} \right )}}{2 b^{2} \sin ^{2}{\left (x \right )} \tan ^{4}{\left (\frac {x}{2} \right )} - 4 b^{2} \sin ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )} + 2 b^{2} \sin ^{2}{\left (x \right )} + 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan ^{3}{\left (\frac {x}{2} \right )} - 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan {\left (\frac {x}{2} \right )} + 8 b^{2} \cos ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )}} - \frac {2 \tan {\left (\frac {x}{2} \right )}}{2 b^{2} \sin ^{2}{\left (x \right )} \tan ^{4}{\left (\frac {x}{2} \right )} - 4 b^{2} \sin ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )} + 2 b^{2} \sin ^{2}{\left (x \right )} + 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan ^{3}{\left (\frac {x}{2} \right )} - 8 b^{2} \sin {\left (x \right )} \cos {\left (x \right )} \tan {\left (\frac {x}{2} \right )} + 8 b^{2} \cos ^{2}{\left (x \right )} \tan ^{2}{\left (\frac {x}{2} \right )}} & \text {for}\: a = \frac {b \left (\tan {\left (\frac {x}{2} \right )} - 1\right ) \left (\tan {\left (\frac {x}{2} \right )} + 1\right )}{2 \tan {\left (\frac {x}{2} \right )}} \\\frac {\frac {\tan {\left (\frac {x}{2} \right )}}{2} - \frac {1}{2 \tan {\left (\frac {x}{2} \right )}}}{a^{2}} & \text {for}\: b = 0 \\\frac {2 \tan {\left (\frac {x}{2} \right )}}{2 a b \tan {\left (\frac {x}{2} \right )} - b^{2} \tan ^{2}{\left (\frac {x}{2} \right )} + b^{2}} & \text {otherwise} \end {cases} \]

[In]

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

[Out]

Piecewise((zoo*tan(x/2)/(tan(x/2)**2 - 1), Eq(a, 0) & Eq(b, 0)), (x*tan(x/2)**4/(2*b**2*sin(x)**2*tan(x/2)**4
- 4*b**2*sin(x)**2*tan(x/2)**2 + 2*b**2*sin(x)**2 + 8*b**2*sin(x)*cos(x)*tan(x/2)**3 - 8*b**2*sin(x)*cos(x)*ta
n(x/2) + 8*b**2*cos(x)**2*tan(x/2)**2) + 2*x*tan(x/2)**2/(2*b**2*sin(x)**2*tan(x/2)**4 - 4*b**2*sin(x)**2*tan(
x/2)**2 + 2*b**2*sin(x)**2 + 8*b**2*sin(x)*cos(x)*tan(x/2)**3 - 8*b**2*sin(x)*cos(x)*tan(x/2) + 8*b**2*cos(x)*
*2*tan(x/2)**2) + x/(2*b**2*sin(x)**2*tan(x/2)**4 - 4*b**2*sin(x)**2*tan(x/2)**2 + 2*b**2*sin(x)**2 + 8*b**2*s
in(x)*cos(x)*tan(x/2)**3 - 8*b**2*sin(x)*cos(x)*tan(x/2) + 8*b**2*cos(x)**2*tan(x/2)**2) + 2*tan(x/2)**3/(2*b*
*2*sin(x)**2*tan(x/2)**4 - 4*b**2*sin(x)**2*tan(x/2)**2 + 2*b**2*sin(x)**2 + 8*b**2*sin(x)*cos(x)*tan(x/2)**3
- 8*b**2*sin(x)*cos(x)*tan(x/2) + 8*b**2*cos(x)**2*tan(x/2)**2) - 2*tan(x/2)/(2*b**2*sin(x)**2*tan(x/2)**4 - 4
*b**2*sin(x)**2*tan(x/2)**2 + 2*b**2*sin(x)**2 + 8*b**2*sin(x)*cos(x)*tan(x/2)**3 - 8*b**2*sin(x)*cos(x)*tan(x
/2) + 8*b**2*cos(x)**2*tan(x/2)**2), Eq(a, b*(tan(x/2) - 1)*(tan(x/2) + 1)/(2*tan(x/2)))), ((tan(x/2)/2 - 1/(2
*tan(x/2)))/a**2, Eq(b, 0)), (2*tan(x/2)/(2*a*b*tan(x/2) - b**2*tan(x/2)**2 + b**2), True))

Maxima [A] (verification not implemented)

none

Time = 0.18 (sec) , antiderivative size = 14, normalized size of antiderivative = 0.82 \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=-\frac {1}{a^{2} \tan \left (x\right ) + a b} \]

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 13, normalized size of antiderivative = 0.76 \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=-\frac {1}{{\left (a \tan \left (x\right ) + b\right )} a} \]

[In]

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

[Out]

-1/((a*tan(x) + b)*a)

Mupad [B] (verification not implemented)

Time = 0.65 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.71 \[ \int \frac {1}{(b \cos (x)+a \sin (x))^2} \, dx=\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )}{b\,\left (-b\,{\mathrm {tan}\left (\frac {x}{2}\right )}^2+2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )+b\right )} \]

[In]

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

[Out]

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