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

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

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.259909, antiderivative size = 105, normalized size of antiderivative = 1., number of steps used = 8, number of rules used = 5, integrand size = 17, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.294, Rules used = {4401, 2659, 205, 2695, 2735} \[ \frac{2 a \tan ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{x}{2}\right )}{\sqrt{c+d}}\right )}{\sqrt{c-d} \sqrt{c+d}}+\frac{b c x}{d^2}-\frac{2 b \sqrt{c-d} \sqrt{c+d} \tan ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{x}{2}\right )}{\sqrt{c+d}}\right )}{d^2}-\frac{b \sin (x)}{d} \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 4401

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

Rule 2659

Int[((a_) + (b_.)*sin[Pi/2 + (c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = FreeFactors[Tan[(c + d*x)/2], x
]}, Dist[(2*e)/d, Subst[Int[1/(a + b + (a - b)*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 205

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

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 \sin ^2(x)}{c+d \cos (x)} \, dx &=\int \left (\frac{a}{c+d \cos (x)}+\frac{b \sin ^2(x)}{c+d \cos (x)}\right ) \, dx\\ &=a \int \frac{1}{c+d \cos (x)} \, dx+b \int \frac{\sin ^2(x)}{c+d \cos (x)} \, dx\\ &=-\frac{b \sin (x)}{d}+(2 a) \operatorname{Subst}\left (\int \frac{1}{c+d+(c-d) x^2} \, dx,x,\tan \left (\frac{x}{2}\right )\right )-\frac{b \int \frac{-d-c \cos (x)}{c+d \cos (x)} \, dx}{d}\\ &=\frac{b c x}{d^2}+\frac{2 a \tan ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{x}{2}\right )}{\sqrt{c+d}}\right )}{\sqrt{c-d} \sqrt{c+d}}-\frac{b \sin (x)}{d}+\frac{\left (b \left (-c^2+d^2\right )\right ) \int \frac{1}{c+d \cos (x)} \, dx}{d^2}\\ &=\frac{b c x}{d^2}+\frac{2 a \tan ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{x}{2}\right )}{\sqrt{c+d}}\right )}{\sqrt{c-d} \sqrt{c+d}}-\frac{b \sin (x)}{d}+\frac{\left (2 b \left (-c^2+d^2\right )\right ) \operatorname{Subst}\left (\int \frac{1}{c+d+(c-d) 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{\sqrt{c-d} \tan \left (\frac{x}{2}\right )}{\sqrt{c+d}}\right )}{\sqrt{c-d} \sqrt{c+d}}-\frac{2 b \sqrt{c-d} \sqrt{c+d} \tan ^{-1}\left (\frac{\sqrt{c-d} \tan \left (\frac{x}{2}\right )}{\sqrt{c+d}}\right )}{d^2}-\frac{b \sin (x)}{d}\\ \end{align*}

Mathematica [A]  time = 0.153592, size = 73, normalized size = 0.7 \[ \frac{-\frac{2 \left (a d^2+b \left (d^2-c^2\right )\right ) \tanh ^{-1}\left (\frac{(c-d) \tan \left (\frac{x}{2}\right )}{\sqrt{d^2-c^2}}\right )}{\sqrt{d^2-c^2}}+b c x-b d \sin (x)}{d^2} \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [A]  time = 0.042, size = 148, normalized size = 1.4 \begin{align*} 2\,{\frac{a}{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}\arctan \left ({\frac{ \left ( c-d \right ) \tan \left ( x/2 \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) }-2\,{\frac{b{c}^{2}}{{d}^{2}\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}\arctan \left ({\frac{ \left ( c-d \right ) \tan \left ( x/2 \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) }+2\,{\frac{b}{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}\arctan \left ({\frac{ \left ( c-d \right ) \tan \left ( x/2 \right ) }{\sqrt{ \left ( c+d \right ) \left ( c-d \right ) }}} \right ) }-2\,{\frac{b\tan \left ( x/2 \right ) }{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*sin(x)^2)/(c+d*cos(x)),x)

[Out]

2/((c+d)*(c-d))^(1/2)*arctan((c-d)*tan(1/2*x)/((c+d)*(c-d))^(1/2))*a-2/d^2/((c+d)*(c-d))^(1/2)*arctan((c-d)*ta
n(1/2*x)/((c+d)*(c-d))^(1/2))*b*c^2+2/((c+d)*(c-d))^(1/2)*arctan((c-d)*tan(1/2*x)/((c+d)*(c-d))^(1/2))*b-2*b/d
*tan(1/2*x)/(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*sin(x)^2)/(c+d*cos(x)),x, algorithm="maxima")

[Out]

Exception raised: ValueError

________________________________________________________________________________________

Fricas [A]  time = 2.72175, size = 558, normalized size = 5.31 \begin{align*} \left [\frac{{\left (b c^{2} -{\left (a + b\right )} d^{2}\right )} \sqrt{-c^{2} + d^{2}} \log \left (\frac{2 \, c d \cos \left (x\right ) +{\left (2 \, c^{2} - d^{2}\right )} \cos \left (x\right )^{2} + 2 \, \sqrt{-c^{2} + d^{2}}{\left (c \cos \left (x\right ) + d\right )} \sin \left (x\right ) - c^{2} + 2 \, d^{2}}{d^{2} \cos \left (x\right )^{2} + 2 \, c d \cos \left (x\right ) + c^{2}}\right ) + 2 \,{\left (b c^{3} - b c d^{2}\right )} x - 2 \,{\left (b c^{2} d - b d^{3}\right )} \sin \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 \cos \left (x\right ) + d}{\sqrt{c^{2} - d^{2}} \sin \left (x\right )}\right ) -{\left (b c^{3} - b c d^{2}\right )} x +{\left (b c^{2} d - b d^{3}\right )} \sin \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*sin(x)^2)/(c+d*cos(x)),x, algorithm="fricas")

[Out]

[1/2*((b*c^2 - (a + b)*d^2)*sqrt(-c^2 + d^2)*log((2*c*d*cos(x) + (2*c^2 - d^2)*cos(x)^2 + 2*sqrt(-c^2 + d^2)*(
c*cos(x) + d)*sin(x) - c^2 + 2*d^2)/(d^2*cos(x)^2 + 2*c*d*cos(x) + c^2)) + 2*(b*c^3 - b*c*d^2)*x - 2*(b*c^2*d
- b*d^3)*sin(x))/(c^2*d^2 - d^4), -((b*c^2 - (a + b)*d^2)*sqrt(c^2 - d^2)*arctan(-(c*cos(x) + d)/(sqrt(c^2 - d
^2)*sin(x))) - (b*c^3 - b*c*d^2)*x + (b*c^2*d - b*d^3)*sin(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*sin(x)**2)/(c+d*cos(x)),x)

[Out]

Timed out

________________________________________________________________________________________

Giac [A]  time = 1.14017, size = 149, normalized size = 1.42 \begin{align*} \frac{b c x}{d^{2}} - \frac{2 \, b \tan \left (\frac{1}{2} \, x\right )}{{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right )} d} + \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 (-2 \, c + 2 \, d\right ) + \arctan \left (-\frac{c \tan \left (\frac{1}{2} \, x\right ) - d \tan \left (\frac{1}{2} \, x\right )}{\sqrt{c^{2} - d^{2}}}\right )\right )}}{\sqrt{c^{2} - d^{2}} d^{2}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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