\(\int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx\) [879]

Optimal result
Mathematica [A] (warning: unable to verify)
Rubi [A] (verified)
Maple [B] (verified)
Fricas [F(-1)]
Sympy [F(-1)]
Maxima [F]
Giac [F]
Mupad [F(-1)]
Reduce [F]

Optimal result

Integrand size = 42, antiderivative size = 89 \[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\frac {2 C E\left (\left .\frac {1}{2} (c+d x)\right |2\right )}{b d}+\frac {2 (b B-a C) \operatorname {EllipticF}\left (\frac {1}{2} (c+d x),2\right )}{b^2 d}-\frac {2 a (b B-a C) \operatorname {EllipticPi}\left (\frac {2 b}{a+b},\frac {1}{2} (c+d x),2\right )}{b^2 (a+b) d} \] Output:

2*C*EllipticE(sin(1/2*d*x+1/2*c),2^(1/2))/b/d+2*(B*b-C*a)*InverseJacobiAM( 
1/2*d*x+1/2*c,2^(1/2))/b^2/d-2*a*(B*b-C*a)*EllipticPi(sin(1/2*d*x+1/2*c),2 
*b/(a+b),2^(1/2))/b^2/(a+b)/d
 

Mathematica [A] (warning: unable to verify)

Time = 1.11 (sec) , antiderivative size = 128, normalized size of antiderivative = 1.44 \[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\frac {b B \left (2 \operatorname {EllipticF}\left (\frac {1}{2} (c+d x),2\right )-\frac {2 a \operatorname {EllipticPi}\left (\frac {2 b}{a+b},\frac {1}{2} (c+d x),2\right )}{a+b}\right )-\frac {2 C \left (b E\left (\left .\arcsin \left (\sqrt {\cos (c+d x)}\right )\right |-1\right )-(a+b) \operatorname {EllipticF}\left (\arcsin \left (\sqrt {\cos (c+d x)}\right ),-1\right )+a \operatorname {EllipticPi}\left (-\frac {b}{a},\arcsin \left (\sqrt {\cos (c+d x)}\right ),-1\right )\right ) \sin (c+d x)}{\sqrt {\sin ^2(c+d x)}}}{b^2 d} \] Input:

Integrate[(B*Cos[c + d*x] + C*Cos[c + d*x]^2)/(Sqrt[Cos[c + d*x]]*(a + b*C 
os[c + d*x])),x]
 

Output:

(b*B*(2*EllipticF[(c + d*x)/2, 2] - (2*a*EllipticPi[(2*b)/(a + b), (c + d* 
x)/2, 2])/(a + b)) - (2*C*(b*EllipticE[ArcSin[Sqrt[Cos[c + d*x]]], -1] - ( 
a + b)*EllipticF[ArcSin[Sqrt[Cos[c + d*x]]], -1] + a*EllipticPi[-(b/a), Ar 
cSin[Sqrt[Cos[c + d*x]]], -1])*Sin[c + d*x])/Sqrt[Sin[c + d*x]^2])/(b^2*d)
 

Rubi [A] (verified)

Time = 0.71 (sec) , antiderivative size = 86, normalized size of antiderivative = 0.97, number of steps used = 10, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.238, Rules used = {3042, 3508, 3042, 3481, 3042, 3119, 3282, 3042, 3120, 3284}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {B \sin \left (c+d x+\frac {\pi }{2}\right )+C \sin \left (c+d x+\frac {\pi }{2}\right )^2}{\sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )} \left (a+b \sin \left (c+d x+\frac {\pi }{2}\right )\right )}dx\)

\(\Big \downarrow \) 3508

\(\displaystyle \int \frac {\sqrt {\cos (c+d x)} (B+C \cos (c+d x))}{a+b \cos (c+d x)}dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )} \left (B+C \sin \left (c+d x+\frac {\pi }{2}\right )\right )}{a+b \sin \left (c+d x+\frac {\pi }{2}\right )}dx\)

\(\Big \downarrow \) 3481

\(\displaystyle \frac {(b B-a C) \int \frac {\sqrt {\cos (c+d x)}}{a+b \cos (c+d x)}dx}{b}+\frac {C \int \sqrt {\cos (c+d x)}dx}{b}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {(b B-a C) \int \frac {\sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )}}{a+b \sin \left (c+d x+\frac {\pi }{2}\right )}dx}{b}+\frac {C \int \sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )}dx}{b}\)

\(\Big \downarrow \) 3119

\(\displaystyle \frac {(b B-a C) \int \frac {\sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )}}{a+b \sin \left (c+d x+\frac {\pi }{2}\right )}dx}{b}+\frac {2 C E\left (\left .\frac {1}{2} (c+d x)\right |2\right )}{b d}\)

\(\Big \downarrow \) 3282

\(\displaystyle \frac {(b B-a C) \left (\frac {\int \frac {1}{\sqrt {\cos (c+d x)}}dx}{b}-\frac {a \int \frac {1}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))}dx}{b}\right )}{b}+\frac {2 C E\left (\left .\frac {1}{2} (c+d x)\right |2\right )}{b d}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {(b B-a C) \left (\frac {\int \frac {1}{\sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )}}dx}{b}-\frac {a \int \frac {1}{\sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )} \left (a+b \sin \left (c+d x+\frac {\pi }{2}\right )\right )}dx}{b}\right )}{b}+\frac {2 C E\left (\left .\frac {1}{2} (c+d x)\right |2\right )}{b d}\)

\(\Big \downarrow \) 3120

\(\displaystyle \frac {(b B-a C) \left (\frac {2 \operatorname {EllipticF}\left (\frac {1}{2} (c+d x),2\right )}{b d}-\frac {a \int \frac {1}{\sqrt {\sin \left (c+d x+\frac {\pi }{2}\right )} \left (a+b \sin \left (c+d x+\frac {\pi }{2}\right )\right )}dx}{b}\right )}{b}+\frac {2 C E\left (\left .\frac {1}{2} (c+d x)\right |2\right )}{b d}\)

\(\Big \downarrow \) 3284

\(\displaystyle \frac {(b B-a C) \left (\frac {2 \operatorname {EllipticF}\left (\frac {1}{2} (c+d x),2\right )}{b d}-\frac {2 a \operatorname {EllipticPi}\left (\frac {2 b}{a+b},\frac {1}{2} (c+d x),2\right )}{b d (a+b)}\right )}{b}+\frac {2 C E\left (\left .\frac {1}{2} (c+d x)\right |2\right )}{b d}\)

Input:

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

Output:

(2*C*EllipticE[(c + d*x)/2, 2])/(b*d) + ((b*B - a*C)*((2*EllipticF[(c + d* 
x)/2, 2])/(b*d) - (2*a*EllipticPi[(2*b)/(a + b), (c + d*x)/2, 2])/(b*(a + 
b)*d)))/b
 

Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3119
Int[Sqrt[sin[(c_.) + (d_.)*(x_)]], x_Symbol] :> Simp[(2/d)*EllipticE[(1/2)* 
(c - Pi/2 + d*x), 2], x] /; FreeQ[{c, d}, x]
 

rule 3120
Int[1/Sqrt[sin[(c_.) + (d_.)*(x_)]], x_Symbol] :> Simp[(2/d)*EllipticF[(1/2 
)*(c - Pi/2 + d*x), 2], x] /; FreeQ[{c, d}, x]
 

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

rule 3284
Int[1/(((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])*Sqrt[(c_.) + (d_.)*sin[(e_.) 
 + (f_.)*(x_)]]), x_Symbol] :> Simp[(2/(f*(a + b)*Sqrt[c + d]))*EllipticPi[ 
2*(b/(a + b)), (1/2)*(e - Pi/2 + f*x), 2*(d/(c + d))], x] /; FreeQ[{a, b, c 
, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 
0] && GtQ[c + d, 0]
 

rule 3481
Int[(((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*sin[(e_.) 
+ (f_.)*(x_)]))/((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[ 
B/d   Int[(a + b*Sin[e + f*x])^m, x], x] - Simp[(B*c - A*d)/d   Int[(a + b* 
Sin[e + f*x])^m/(c + d*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, A, 
 B, m}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0]
 

rule 3508
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*sin[(e_.) 
+ (f_.)*(x_)])^(n_.)*((A_.) + (B_.)*sin[(e_.) + (f_.)*(x_)] + (C_.)*sin[(e_ 
.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[1/b^2   Int[(a + b*Sin[e + f*x])^(m 
+ 1)*(c + d*Sin[e + f*x])^n*(b*B - a*C + b*C*Sin[e + f*x]), x], x] /; FreeQ 
[{a, b, c, d, e, f, A, B, C, m, n}, x] && NeQ[b*c - a*d, 0] && EqQ[A*b^2 - 
a*b*B + a^2*C, 0]
 
Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(294\) vs. \(2(94)=188\).

Time = 4.12 (sec) , antiderivative size = 295, normalized size of antiderivative = 3.31

method result size
default \(-\frac {2 \sqrt {\left (2 \cos \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right ) \sin \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}}\, \sqrt {\frac {1}{2}-\frac {\cos \left (d x +c \right )}{2}}\, \sqrt {1-2 \cos \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}}\, \left (B \operatorname {EllipticF}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), \sqrt {2}\right ) a b -B \operatorname {EllipticF}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), \sqrt {2}\right ) b^{2}-B \operatorname {EllipticPi}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), -\frac {2 b}{a -b}, \sqrt {2}\right ) a b -C \operatorname {EllipticF}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), \sqrt {2}\right ) a^{2}+C \operatorname {EllipticF}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), \sqrt {2}\right ) a b -C \operatorname {EllipticE}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), \sqrt {2}\right ) a b +C \operatorname {EllipticE}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), \sqrt {2}\right ) b^{2}+C \operatorname {EllipticPi}\left (\cos \left (\frac {d x}{2}+\frac {c}{2}\right ), -\frac {2 b}{a -b}, \sqrt {2}\right ) a^{2}\right )}{b^{2} \left (a -b \right ) \sqrt {-2 \sin \left (\frac {d x}{2}+\frac {c}{2}\right )^{4}+\sin \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}}\, \sin \left (\frac {d x}{2}+\frac {c}{2}\right ) \sqrt {2 \cos \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1}\, d}\) \(295\)

Input:

int((B*cos(d*x+c)+C*cos(d*x+c)^2)/cos(d*x+c)^(1/2)/(a+b*cos(d*x+c)),x,meth 
od=_RETURNVERBOSE)
 

Output:

-2*((2*cos(1/2*d*x+1/2*c)^2-1)*sin(1/2*d*x+1/2*c)^2)^(1/2)*(sin(1/2*d*x+1/ 
2*c)^2)^(1/2)*(1-2*cos(1/2*d*x+1/2*c)^2)^(1/2)*(B*EllipticF(cos(1/2*d*x+1/ 
2*c),2^(1/2))*a*b-B*EllipticF(cos(1/2*d*x+1/2*c),2^(1/2))*b^2-B*EllipticPi 
(cos(1/2*d*x+1/2*c),-2*b/(a-b),2^(1/2))*a*b-C*EllipticF(cos(1/2*d*x+1/2*c) 
,2^(1/2))*a^2+C*EllipticF(cos(1/2*d*x+1/2*c),2^(1/2))*a*b-C*EllipticE(cos( 
1/2*d*x+1/2*c),2^(1/2))*a*b+C*EllipticE(cos(1/2*d*x+1/2*c),2^(1/2))*b^2+C* 
EllipticPi(cos(1/2*d*x+1/2*c),-2*b/(a-b),2^(1/2))*a^2)/b^2/(a-b)/(-2*sin(1 
/2*d*x+1/2*c)^4+sin(1/2*d*x+1/2*c)^2)^(1/2)/sin(1/2*d*x+1/2*c)/(2*cos(1/2* 
d*x+1/2*c)^2-1)^(1/2)/d
 

Fricas [F(-1)]

Timed out. \[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\text {Timed out} \] Input:

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

Output:

Timed out
 

Sympy [F(-1)]

Timed out. \[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\text {Timed out} \] Input:

integrate((B*cos(d*x+c)+C*cos(d*x+c)**2)/cos(d*x+c)**(1/2)/(a+b*cos(d*x+c) 
),x)
 

Output:

Timed out
 

Maxima [F]

\[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\int { \frac {C \cos \left (d x + c\right )^{2} + B \cos \left (d x + c\right )}{{\left (b \cos \left (d x + c\right ) + a\right )} \sqrt {\cos \left (d x + c\right )}} \,d x } \] Input:

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

Output:

integrate((C*cos(d*x + c)^2 + B*cos(d*x + c))/((b*cos(d*x + c) + a)*sqrt(c 
os(d*x + c))), x)
 

Giac [F]

\[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\int { \frac {C \cos \left (d x + c\right )^{2} + B \cos \left (d x + c\right )}{{\left (b \cos \left (d x + c\right ) + a\right )} \sqrt {\cos \left (d x + c\right )}} \,d x } \] Input:

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

Output:

integrate((C*cos(d*x + c)^2 + B*cos(d*x + c))/((b*cos(d*x + c) + a)*sqrt(c 
os(d*x + c))), x)
 

Mupad [F(-1)]

Timed out. \[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\int \frac {C\,{\cos \left (c+d\,x\right )}^2+B\,\cos \left (c+d\,x\right )}{\sqrt {\cos \left (c+d\,x\right )}\,\left (a+b\,\cos \left (c+d\,x\right )\right )} \,d x \] Input:

int((B*cos(c + d*x) + C*cos(c + d*x)^2)/(cos(c + d*x)^(1/2)*(a + b*cos(c + 
 d*x))),x)
 

Output:

int((B*cos(c + d*x) + C*cos(c + d*x)^2)/(cos(c + d*x)^(1/2)*(a + b*cos(c + 
 d*x))), x)
 

Reduce [F]

\[ \int \frac {B \cos (c+d x)+C \cos ^2(c+d x)}{\sqrt {\cos (c+d x)} (a+b \cos (c+d x))} \, dx=\left (\int \frac {\sqrt {\cos \left (d x +c \right )}}{\cos \left (d x +c \right ) b +a}d x \right ) b +\left (\int \frac {\sqrt {\cos \left (d x +c \right )}\, \cos \left (d x +c \right )}{\cos \left (d x +c \right ) b +a}d x \right ) c \] Input:

int((B*cos(d*x+c)+C*cos(d*x+c)^2)/cos(d*x+c)^(1/2)/(a+b*cos(d*x+c)),x)
 

Output:

int(sqrt(cos(c + d*x))/(cos(c + d*x)*b + a),x)*b + int((sqrt(cos(c + d*x)) 
*cos(c + d*x))/(cos(c + d*x)*b + a),x)*c