3.211 \(\int \frac{a+b \cos ^2(x)}{c+d \sin (x)} \, dx\)

Optimal. Leaf size=100 \[ \frac{2 a \tan ^{-1}\left (\frac{c \tan \left (\frac{x}{2}\right )+d}{\sqrt{c^2-d^2}}\right )}{\sqrt{c^2-d^2}}-\frac{2 b \sqrt{c^2-d^2} \tan ^{-1}\left (\frac{c \tan \left (\frac{x}{2}\right )+d}{\sqrt{c^2-d^2}}\right )}{d^2}+\frac{b c x}{d^2}+\frac{b \cos (x)}{d} \]

[Out]

(b*c*x)/d^2 + (2*a*ArcTan[(d + c*Tan[x/2])/Sqrt[c^2 - d^2]])/Sqrt[c^2 - d^2] - (2*b*Sqrt[c^2 - d^2]*ArcTan[(d
+ c*Tan[x/2])/Sqrt[c^2 - d^2]])/d^2 + (b*Cos[x])/d

________________________________________________________________________________________

Rubi [A]  time = 0.240105, antiderivative size = 100, normalized size of antiderivative = 1., number of steps used = 10, number of rules used = 6, integrand size = 17, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.353, Rules used = {4401, 2660, 618, 204, 2695, 2735} \[ \frac{2 a \tan ^{-1}\left (\frac{c \tan \left (\frac{x}{2}\right )+d}{\sqrt{c^2-d^2}}\right )}{\sqrt{c^2-d^2}}-\frac{2 b \sqrt{c^2-d^2} \tan ^{-1}\left (\frac{c \tan \left (\frac{x}{2}\right )+d}{\sqrt{c^2-d^2}}\right )}{d^2}+\frac{b c x}{d^2}+\frac{b \cos (x)}{d} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Cos[x]^2)/(c + d*Sin[x]),x]

[Out]

(b*c*x)/d^2 + (2*a*ArcTan[(d + c*Tan[x/2])/Sqrt[c^2 - d^2]])/Sqrt[c^2 - d^2] - (2*b*Sqrt[c^2 - d^2]*ArcTan[(d
+ c*Tan[x/2])/Sqrt[c^2 - d^2]])/d^2 + (b*Cos[x])/d

Rule 4401

Int[u_, x_Symbol] :> With[{v = ExpandTrig[u, x]}, Int[v, x] /; SumQ[v]] /;  !InertTrigFreeQ[u]

Rule 2660

Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x]}, Dis
t[(2*e)/d, Subst[Int[1/(a + 2*b*e*x + a*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] &&
 NeQ[a^2 - b^2, 0]

Rule 618

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

Rule 204

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

Rule 2695

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Simp[(g*(g*
Cos[e + f*x])^(p - 1)*(a + b*Sin[e + f*x])^(m + 1))/(b*f*(m + p)), x] + Dist[(g^2*(p - 1))/(b*(m + p)), Int[(g
*Cos[e + f*x])^(p - 2)*(a + b*Sin[e + f*x])^m*(b + a*Sin[e + f*x]), x], x] /; FreeQ[{a, b, e, f, g, m}, x] &&
NeQ[a^2 - b^2, 0] && GtQ[p, 1] && NeQ[m + p, 0] && IntegersQ[2*m, 2*p]

Rule 2735

Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(b*x)/d
, x] - Dist[(b*c - a*d)/d, Int[1/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d
, 0]

Rubi steps

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

Mathematica [A]  time = 0.189639, size = 72, normalized size = 0.72 \[ \frac{\frac{2 \left (a d^2+b \left (d^2-c^2\right )\right ) \tan ^{-1}\left (\frac{c \tan \left (\frac{x}{2}\right )+d}{\sqrt{c^2-d^2}}\right )}{\sqrt{c^2-d^2}}+b (c x+d \cos (x))}{d^2} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Cos[x]^2)/(c + d*Sin[x]),x]

[Out]

((2*(a*d^2 + b*(-c^2 + d^2))*ArcTan[(d + c*Tan[x/2])/Sqrt[c^2 - d^2]])/Sqrt[c^2 - d^2] + b*(c*x + d*Cos[x]))/d
^2

________________________________________________________________________________________

Maple [A]  time = 0.033, size = 153, normalized size = 1.5 \begin{align*} 2\,{\frac{a}{\sqrt{{c}^{2}-{d}^{2}}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( x/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }-2\,{\frac{{c}^{2}b}{{d}^{2}\sqrt{{c}^{2}-{d}^{2}}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( x/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }+2\,{\frac{b}{\sqrt{{c}^{2}-{d}^{2}}}\arctan \left ( 1/2\,{\frac{2\,c\tan \left ( x/2 \right ) +2\,d}{\sqrt{{c}^{2}-{d}^{2}}}} \right ) }+2\,{\frac{b}{d \left ( 1+ \left ( \tan \left ( x/2 \right ) \right ) ^{2} \right ) }}+2\,{\frac{cb\arctan \left ( \tan \left ( x/2 \right ) \right ) }{{d}^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: ValueError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [A]  time = 2.63432, size = 571, normalized size = 5.71 \begin{align*} \left [\frac{{\left (b c^{2} -{\left (a + b\right )} d^{2}\right )} \sqrt{-c^{2} + d^{2}} \log \left (\frac{{\left (2 \, c^{2} - d^{2}\right )} \cos \left (x\right )^{2} - 2 \, c d \sin \left (x\right ) - c^{2} - d^{2} + 2 \,{\left (c \cos \left (x\right ) \sin \left (x\right ) + d \cos \left (x\right )\right )} \sqrt{-c^{2} + d^{2}}}{d^{2} \cos \left (x\right )^{2} - 2 \, c d \sin \left (x\right ) - c^{2} - d^{2}}\right ) + 2 \,{\left (b c^{3} - b c d^{2}\right )} x + 2 \,{\left (b c^{2} d - b d^{3}\right )} \cos \left (x\right )}{2 \,{\left (c^{2} d^{2} - d^{4}\right )}}, \frac{{\left (b c^{2} -{\left (a + b\right )} d^{2}\right )} \sqrt{c^{2} - d^{2}} \arctan \left (-\frac{c \sin \left (x\right ) + d}{\sqrt{c^{2} - d^{2}} \cos \left (x\right )}\right ) +{\left (b c^{3} - b c d^{2}\right )} x +{\left (b c^{2} d - b d^{3}\right )} \cos \left (x\right )}{c^{2} d^{2} - d^{4}}\right ] \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

[1/2*((b*c^2 - (a + b)*d^2)*sqrt(-c^2 + d^2)*log(((2*c^2 - d^2)*cos(x)^2 - 2*c*d*sin(x) - c^2 - d^2 + 2*(c*cos
(x)*sin(x) + d*cos(x))*sqrt(-c^2 + d^2))/(d^2*cos(x)^2 - 2*c*d*sin(x) - c^2 - d^2)) + 2*(b*c^3 - b*c*d^2)*x +
2*(b*c^2*d - b*d^3)*cos(x))/(c^2*d^2 - d^4), ((b*c^2 - (a + b)*d^2)*sqrt(c^2 - d^2)*arctan(-(c*sin(x) + d)/(sq
rt(c^2 - d^2)*cos(x))) + (b*c^3 - b*c*d^2)*x + (b*c^2*d - b*d^3)*cos(x))/(c^2*d^2 - d^4)]

________________________________________________________________________________________

Sympy [F(-1)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Timed out} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Timed out

________________________________________________________________________________________

Giac [A]  time = 1.16553, size = 126, normalized size = 1.26 \begin{align*} \frac{b c x}{d^{2}} - \frac{2 \,{\left (b c^{2} - a d^{2} - b d^{2}\right )}{\left (\pi \left \lfloor \frac{x}{2 \, \pi } + \frac{1}{2} \right \rfloor \mathrm{sgn}\left (c\right ) + \arctan \left (\frac{c \tan \left (\frac{1}{2} \, x\right ) + d}{\sqrt{c^{2} - d^{2}}}\right )\right )}}{\sqrt{c^{2} - d^{2}} d^{2}} + \frac{2 \, b}{{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right )} d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

b*c*x/d^2 - 2*(b*c^2 - a*d^2 - b*d^2)*(pi*floor(1/2*x/pi + 1/2)*sgn(c) + arctan((c*tan(1/2*x) + d)/sqrt(c^2 -
d^2)))/(sqrt(c^2 - d^2)*d^2) + 2*b/((tan(1/2*x)^2 + 1)*d)