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+b*cos(x)/d+2*a*arctan((d+c*tan(1/2*x))/(c^2-d^2)^(1/2))/(c^2-d^2)^(1/2)-2*b*arctan((d+c*tan(1/2*x))/
(c^2-d^2)^(1/2))*(c^2-d^2)^(1/2)/d^2

________________________________________________________________________________________

Rubi [A]  time = 0.24, antiderivative size = 100, normalized size of antiderivative = 1.00, 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 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 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 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 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]

Rule 4401

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

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.18, 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

________________________________________________________________________________________

fricas [A]  time = 0.78, size = 262, normalized size = 2.62 \[ \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 \relax (x)^{2} - 2 \, c d \sin \relax (x) - c^{2} - d^{2} + 2 \, {\left (c \cos \relax (x) \sin \relax (x) + d \cos \relax (x)\right )} \sqrt {-c^{2} + d^{2}}}{d^{2} \cos \relax (x)^{2} - 2 \, c d \sin \relax (x) - 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 \relax (x)}{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 \relax (x) + d}{\sqrt {c^{2} - d^{2}} \cos \relax (x)}\right ) + {\left (b c^{3} - b c d^{2}\right )} x + {\left (b c^{2} d - b d^{3}\right )} \cos \relax (x)}{c^{2} d^{2} - d^{4}}\right ] \]

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)]

________________________________________________________________________________________

giac [A]  time = 0.15, size = 93, normalized size = 0.93 \[ \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}\relax (c) + \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} \]

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)

________________________________________________________________________________________

maple [A]  time = 0.08, size = 153, normalized size = 1.53 \[ \frac {2 \arctan \left (\frac {2 c \tan \left (\frac {x}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right ) a}{\sqrt {c^{2}-d^{2}}}-\frac {2 \arctan \left (\frac {2 c \tan \left (\frac {x}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right ) c^{2} b}{d^{2} \sqrt {c^{2}-d^{2}}}+\frac {2 \arctan \left (\frac {2 c \tan \left (\frac {x}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right ) b}{\sqrt {c^{2}-d^{2}}}+\frac {2 b}{d \left (1+\tan ^{2}\left (\frac {x}{2}\right )\right )}+\frac {2 b c \arctan \left (\tan \left (\frac {x}{2}\right )\right )}{d^{2}} \]

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.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]

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 >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*d^2-4*c^2>0)', see `assume?`
 for more details)Is 4*d^2-4*c^2 positive or negative?

________________________________________________________________________________________

mupad [B]  time = 5.15, size = 1646, normalized size = 16.46 \[ \text {result too large to display} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

(2*b)/(d*(tan(x/2)^2 + 1)) - (atan((((-(c + d)*(c - d))^(1/2)*((32*b^2*c^4)/d - (32*tan(x/2)*(a^2*c*d^5 + b^2*
c*d^5 + 2*b^2*c^5*d - 4*b^2*c^3*d^3 + 2*a*b*c*d^5 - 2*a*b*c^3*d^3))/d^3 + ((-(c + d)*(c - d))^(1/2)*(32*a*c^2*
d^2 + (32*tan(x/2)*(2*a*c*d^6 - 2*b*c^3*d^4 + 2*b*c*d^6))/d^3 + ((-(c + d)*(c - d))^(1/2)*(32*c^2*d^3 + (32*ta
n(x/2)*(3*c*d^7 - 2*c^3*d^5))/d^3)*(a*d^2 - b*c^2 + b*d^2))/(d^4 - c^2*d^2))*(a*d^2 - b*c^2 + b*d^2))/(d^4 - c
^2*d^2))*(a*d^2 - b*c^2 + b*d^2)*1i)/(d^4 - c^2*d^2) - ((-(c + d)*(c - d))^(1/2)*((32*tan(x/2)*(a^2*c*d^5 + b^
2*c*d^5 + 2*b^2*c^5*d - 4*b^2*c^3*d^3 + 2*a*b*c*d^5 - 2*a*b*c^3*d^3))/d^3 - (32*b^2*c^4)/d + ((-(c + d)*(c - d
))^(1/2)*(32*a*c^2*d^2 + (32*tan(x/2)*(2*a*c*d^6 - 2*b*c^3*d^4 + 2*b*c*d^6))/d^3 - ((-(c + d)*(c - d))^(1/2)*(
32*c^2*d^3 + (32*tan(x/2)*(3*c*d^7 - 2*c^3*d^5))/d^3)*(a*d^2 - b*c^2 + b*d^2))/(d^4 - c^2*d^2))*(a*d^2 - b*c^2
 + b*d^2))/(d^4 - c^2*d^2))*(a*d^2 - b*c^2 + b*d^2)*1i)/(d^4 - c^2*d^2))/((64*(b^3*c^2*d^2 - a*b^2*c^4 - b^3*c
^4 + 2*a*b^2*c^2*d^2 + a^2*b*c^2*d^2))/d^2 + (64*tan(x/2)*(2*b^3*c^3*d^2 - 2*b^3*c^5 + 2*a*b^2*c^3*d^2))/d^3 +
 ((-(c + d)*(c - d))^(1/2)*((32*b^2*c^4)/d - (32*tan(x/2)*(a^2*c*d^5 + b^2*c*d^5 + 2*b^2*c^5*d - 4*b^2*c^3*d^3
 + 2*a*b*c*d^5 - 2*a*b*c^3*d^3))/d^3 + ((-(c + d)*(c - d))^(1/2)*(32*a*c^2*d^2 + (32*tan(x/2)*(2*a*c*d^6 - 2*b
*c^3*d^4 + 2*b*c*d^6))/d^3 + ((-(c + d)*(c - d))^(1/2)*(32*c^2*d^3 + (32*tan(x/2)*(3*c*d^7 - 2*c^3*d^5))/d^3)*
(a*d^2 - b*c^2 + b*d^2))/(d^4 - c^2*d^2))*(a*d^2 - b*c^2 + b*d^2))/(d^4 - c^2*d^2))*(a*d^2 - b*c^2 + b*d^2))/(
d^4 - c^2*d^2) + ((-(c + d)*(c - d))^(1/2)*((32*tan(x/2)*(a^2*c*d^5 + b^2*c*d^5 + 2*b^2*c^5*d - 4*b^2*c^3*d^3
+ 2*a*b*c*d^5 - 2*a*b*c^3*d^3))/d^3 - (32*b^2*c^4)/d + ((-(c + d)*(c - d))^(1/2)*(32*a*c^2*d^2 + (32*tan(x/2)*
(2*a*c*d^6 - 2*b*c^3*d^4 + 2*b*c*d^6))/d^3 - ((-(c + d)*(c - d))^(1/2)*(32*c^2*d^3 + (32*tan(x/2)*(3*c*d^7 - 2
*c^3*d^5))/d^3)*(a*d^2 - b*c^2 + b*d^2))/(d^4 - c^2*d^2))*(a*d^2 - b*c^2 + b*d^2))/(d^4 - c^2*d^2))*(a*d^2 - b
*c^2 + b*d^2))/(d^4 - c^2*d^2)))*(-(c + d)*(c - d))^(1/2)*(a*d^2 - b*c^2 + b*d^2)*2i)/(d^4 - c^2*d^2) + (2*b*c
*atan((64*b^3*c^2*tan(x/2))/(64*b^3*c^2 + 128*a*b^2*c^2 + 64*a^2*b*c^2 - (64*b^3*c^4)/d^2 - (128*a*b^2*c^4)/d^
2) - (64*b^3*c^4*tan(x/2))/(64*b^3*c^2*d^2 - 128*a*b^2*c^4 - 64*b^3*c^4 + 128*a*b^2*c^2*d^2 + 64*a^2*b*c^2*d^2
) - (128*a*b^2*c^4*tan(x/2))/(64*b^3*c^2*d^2 - 128*a*b^2*c^4 - 64*b^3*c^4 + 128*a*b^2*c^2*d^2 + 64*a^2*b*c^2*d
^2) + (128*a*b^2*c^2*tan(x/2))/(64*b^3*c^2 + 128*a*b^2*c^2 + 64*a^2*b*c^2 - (64*b^3*c^4)/d^2 - (128*a*b^2*c^4)
/d^2) + (64*a^2*b*c^2*tan(x/2))/(64*b^3*c^2 + 128*a*b^2*c^2 + 64*a^2*b*c^2 - (64*b^3*c^4)/d^2 - (128*a*b^2*c^4
)/d^2)))/d^2

________________________________________________________________________________________

sympy [F(-1)]  time = 0.00, size = 0, normalized size = 0.00 \[ \text {Timed out} \]

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

________________________________________________________________________________________