\(\int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx\) [452]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [F]
Fricas [F]
Sympy [F(-1)]
Maxima [F]
Giac [F]
Mupad [F(-1)]
Reduce [F]

Optimal result

Integrand size = 33, antiderivative size = 287 \[ \int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx=\frac {b (A b (3+m)+a B (4+m)) (c \cos (e+f x))^{1+m} \sin (e+f x)}{c f (2+m) (3+m)}+\frac {b B (c \cos (e+f x))^{1+m} (a+b \cos (e+f x)) \sin (e+f x)}{c f (3+m)}-\frac {\left (A b^2 (1+m)+2 a b B (1+m)+a^2 A (2+m)\right ) (c \cos (e+f x))^{1+m} \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {1+m}{2},\frac {3+m}{2},\cos ^2(e+f x)\right ) \sin (e+f x)}{c f (1+m) (2+m) \sqrt {\sin ^2(e+f x)}}-\frac {\left (b^2 B (2+m)+a (2 A b+a B) (3+m)\right ) (c \cos (e+f x))^{2+m} \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {2+m}{2},\frac {4+m}{2},\cos ^2(e+f x)\right ) \sin (e+f x)}{c^2 f (2+m) (3+m) \sqrt {\sin ^2(e+f x)}} \] Output:

b*(A*b*(3+m)+a*B*(4+m))*(c*cos(f*x+e))^(1+m)*sin(f*x+e)/c/f/(2+m)/(3+m)+b* 
B*(c*cos(f*x+e))^(1+m)*(a+b*cos(f*x+e))*sin(f*x+e)/c/f/(3+m)-(A*b^2*(1+m)+ 
2*a*b*B*(1+m)+a^2*A*(2+m))*(c*cos(f*x+e))^(1+m)*hypergeom([1/2, 1/2+1/2*m] 
,[3/2+1/2*m],cos(f*x+e)^2)*sin(f*x+e)/c/f/(1+m)/(2+m)/(sin(f*x+e)^2)^(1/2) 
-(b^2*B*(2+m)+a*(2*A*b+B*a)*(3+m))*(c*cos(f*x+e))^(2+m)*hypergeom([1/2, 1+ 
1/2*m],[2+1/2*m],cos(f*x+e)^2)*sin(f*x+e)/c^2/f/(2+m)/(3+m)/(sin(f*x+e)^2) 
^(1/2)
 

Mathematica [A] (verified)

Time = 1.79 (sec) , antiderivative size = 211, normalized size of antiderivative = 0.74 \[ \int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx=\frac {(c \cos (e+f x))^m \cot (e+f x) \left (-\frac {a^2 A \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {1+m}{2},\frac {3+m}{2},\cos ^2(e+f x)\right )}{1+m}+\cos (e+f x) \left (-\frac {a (2 A b+a B) \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {2+m}{2},\frac {4+m}{2},\cos ^2(e+f x)\right )}{2+m}+b \cos (e+f x) \left (-\frac {(A b+2 a B) \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {3+m}{2},\frac {5+m}{2},\cos ^2(e+f x)\right )}{3+m}-\frac {b B \cos (e+f x) \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {4+m}{2},\frac {6+m}{2},\cos ^2(e+f x)\right )}{4+m}\right )\right )\right ) \sqrt {\sin ^2(e+f x)}}{f} \] Input:

Integrate[(c*Cos[e + f*x])^m*(a + b*Cos[e + f*x])^2*(A + B*Cos[e + f*x]),x 
]
 

Output:

((c*Cos[e + f*x])^m*Cot[e + f*x]*(-((a^2*A*Hypergeometric2F1[1/2, (1 + m)/ 
2, (3 + m)/2, Cos[e + f*x]^2])/(1 + m)) + Cos[e + f*x]*(-((a*(2*A*b + a*B) 
*Hypergeometric2F1[1/2, (2 + m)/2, (4 + m)/2, Cos[e + f*x]^2])/(2 + m)) + 
b*Cos[e + f*x]*(-(((A*b + 2*a*B)*Hypergeometric2F1[1/2, (3 + m)/2, (5 + m) 
/2, Cos[e + f*x]^2])/(3 + m)) - (b*B*Cos[e + f*x]*Hypergeometric2F1[1/2, ( 
4 + m)/2, (6 + m)/2, Cos[e + f*x]^2])/(4 + m))))*Sqrt[Sin[e + f*x]^2])/f
 

Rubi [A] (verified)

Time = 1.10 (sec) , antiderivative size = 291, normalized size of antiderivative = 1.01, number of steps used = 8, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.242, Rules used = {3042, 3469, 3042, 3502, 3042, 3227, 3042, 3122}

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 (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) (c \cos (e+f x))^m \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \left (a+b \sin \left (e+f x+\frac {\pi }{2}\right )\right )^2 \left (A+B \sin \left (e+f x+\frac {\pi }{2}\right )\right ) \left (c \sin \left (e+f x+\frac {\pi }{2}\right )\right )^mdx\)

\(\Big \downarrow \) 3469

\(\displaystyle \frac {\int (c \cos (e+f x))^m \left (b c (A b (m+3)+a B (m+4)) \cos ^2(e+f x)+c \left (B (m+2) b^2+a (2 A b+a B) (m+3)\right ) \cos (e+f x)+a c (b B (m+1)+a A (m+3))\right )dx}{c (m+3)}+\frac {b B \sin (e+f x) (a+b \cos (e+f x)) (c \cos (e+f x))^{m+1}}{c f (m+3)}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \left (c \sin \left (e+f x+\frac {\pi }{2}\right )\right )^m \left (b c (A b (m+3)+a B (m+4)) \sin \left (e+f x+\frac {\pi }{2}\right )^2+c \left (B (m+2) b^2+a (2 A b+a B) (m+3)\right ) \sin \left (e+f x+\frac {\pi }{2}\right )+a c (b B (m+1)+a A (m+3))\right )dx}{c (m+3)}+\frac {b B \sin (e+f x) (a+b \cos (e+f x)) (c \cos (e+f x))^{m+1}}{c f (m+3)}\)

\(\Big \downarrow \) 3502

\(\displaystyle \frac {\frac {\int (c \cos (e+f x))^m \left ((a (m+2) (b B (m+1)+a A (m+3))+b (m+1) (A b (m+3)+a B (m+4))) c^2+(m+2) \left (B (m+2) b^2+a (2 A b+a B) (m+3)\right ) \cos (e+f x) c^2\right )dx}{c (m+2)}+\frac {b \sin (e+f x) (a B (m+4)+A b (m+3)) (c \cos (e+f x))^{m+1}}{f (m+2)}}{c (m+3)}+\frac {b B \sin (e+f x) (a+b \cos (e+f x)) (c \cos (e+f x))^{m+1}}{c f (m+3)}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {\int \left (c \sin \left (e+f x+\frac {\pi }{2}\right )\right )^m \left ((a (m+2) (b B (m+1)+a A (m+3))+b (m+1) (A b (m+3)+a B (m+4))) c^2+(m+2) \left (B (m+2) b^2+a (2 A b+a B) (m+3)\right ) \sin \left (e+f x+\frac {\pi }{2}\right ) c^2\right )dx}{c (m+2)}+\frac {b \sin (e+f x) (a B (m+4)+A b (m+3)) (c \cos (e+f x))^{m+1}}{f (m+2)}}{c (m+3)}+\frac {b B \sin (e+f x) (a+b \cos (e+f x)) (c \cos (e+f x))^{m+1}}{c f (m+3)}\)

\(\Big \downarrow \) 3227

\(\displaystyle \frac {\frac {c (m+2) \left (a (m+3) (a B+2 A b)+b^2 B (m+2)\right ) \int (c \cos (e+f x))^{m+1}dx+c^2 (a (m+2) (a A (m+3)+b B (m+1))+b (m+1) (a B (m+4)+A b (m+3))) \int (c \cos (e+f x))^mdx}{c (m+2)}+\frac {b \sin (e+f x) (a B (m+4)+A b (m+3)) (c \cos (e+f x))^{m+1}}{f (m+2)}}{c (m+3)}+\frac {b B \sin (e+f x) (a+b \cos (e+f x)) (c \cos (e+f x))^{m+1}}{c f (m+3)}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {c (m+2) \left (a (m+3) (a B+2 A b)+b^2 B (m+2)\right ) \int \left (c \sin \left (e+f x+\frac {\pi }{2}\right )\right )^{m+1}dx+c^2 (a (m+2) (a A (m+3)+b B (m+1))+b (m+1) (a B (m+4)+A b (m+3))) \int \left (c \sin \left (e+f x+\frac {\pi }{2}\right )\right )^mdx}{c (m+2)}+\frac {b \sin (e+f x) (a B (m+4)+A b (m+3)) (c \cos (e+f x))^{m+1}}{f (m+2)}}{c (m+3)}+\frac {b B \sin (e+f x) (a+b \cos (e+f x)) (c \cos (e+f x))^{m+1}}{c f (m+3)}\)

\(\Big \downarrow \) 3122

\(\displaystyle \frac {\frac {-\frac {\sin (e+f x) \left (a (m+3) (a B+2 A b)+b^2 B (m+2)\right ) (c \cos (e+f x))^{m+2} \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {m+2}{2},\frac {m+4}{2},\cos ^2(e+f x)\right )}{f \sqrt {\sin ^2(e+f x)}}-\frac {c \sin (e+f x) (a (m+2) (a A (m+3)+b B (m+1))+b (m+1) (a B (m+4)+A b (m+3))) (c \cos (e+f x))^{m+1} \operatorname {Hypergeometric2F1}\left (\frac {1}{2},\frac {m+1}{2},\frac {m+3}{2},\cos ^2(e+f x)\right )}{f (m+1) \sqrt {\sin ^2(e+f x)}}}{c (m+2)}+\frac {b \sin (e+f x) (a B (m+4)+A b (m+3)) (c \cos (e+f x))^{m+1}}{f (m+2)}}{c (m+3)}+\frac {b B \sin (e+f x) (a+b \cos (e+f x)) (c \cos (e+f x))^{m+1}}{c f (m+3)}\)

Input:

Int[(c*Cos[e + f*x])^m*(a + b*Cos[e + f*x])^2*(A + B*Cos[e + f*x]),x]
 

Output:

(b*B*(c*Cos[e + f*x])^(1 + m)*(a + b*Cos[e + f*x])*Sin[e + f*x])/(c*f*(3 + 
 m)) + ((b*(A*b*(3 + m) + a*B*(4 + m))*(c*Cos[e + f*x])^(1 + m)*Sin[e + f* 
x])/(f*(2 + m)) + (-((c*(a*(2 + m)*(b*B*(1 + m) + a*A*(3 + m)) + b*(1 + m) 
*(A*b*(3 + m) + a*B*(4 + m)))*(c*Cos[e + f*x])^(1 + m)*Hypergeometric2F1[1 
/2, (1 + m)/2, (3 + m)/2, Cos[e + f*x]^2]*Sin[e + f*x])/(f*(1 + m)*Sqrt[Si 
n[e + f*x]^2])) - ((b^2*B*(2 + m) + a*(2*A*b + a*B)*(3 + m))*(c*Cos[e + f* 
x])^(2 + m)*Hypergeometric2F1[1/2, (2 + m)/2, (4 + m)/2, Cos[e + f*x]^2]*S 
in[e + f*x])/(f*Sqrt[Sin[e + f*x]^2]))/(c*(2 + m)))/(c*(3 + m))
 

Defintions of rubi rules used

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

rule 3122
Int[((b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[Cos[c + d*x]*(( 
b*Sin[c + d*x])^(n + 1)/(b*d*(n + 1)*Sqrt[Cos[c + d*x]^2]))*Hypergeometric2 
F1[1/2, (n + 1)/2, (n + 3)/2, Sin[c + d*x]^2], x] /; FreeQ[{b, c, d, n}, x] 
 &&  !IntegerQ[2*n]
 

rule 3227
Int[((b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_) + (d_.)*sin[(e_.) + (f_.)*(x 
_)]), x_Symbol] :> Simp[c   Int[(b*Sin[e + f*x])^m, x], x] + Simp[d/b   Int 
[(b*Sin[e + f*x])^(m + 1), x], x] /; FreeQ[{b, c, d, e, f, m}, x]
 

rule 3469
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*sin[(e_.) + 
 (f_.)*(x_)])*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Si 
mp[(-b)*B*Cos[e + f*x]*(a + b*Sin[e + f*x])^(m - 1)*((c + d*Sin[e + f*x])^( 
n + 1)/(d*f*(m + n + 1))), x] + Simp[1/(d*(m + n + 1))   Int[(a + b*Sin[e + 
 f*x])^(m - 2)*(c + d*Sin[e + f*x])^n*Simp[a^2*A*d*(m + n + 1) + b*B*(b*c*( 
m - 1) + a*d*(n + 1)) + (a*d*(2*A*b + a*B)*(m + n + 1) - b*B*(a*c - b*d*(m 
+ n)))*Sin[e + f*x] + b*(A*b*d*(m + n + 1) - B*(b*c*m - a*d*(2*m + n)))*Sin 
[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, n}, x] && NeQ[b*c 
 - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0] && GtQ[m, 1] &&  !(IGt 
Q[n, 1] && ( !IntegerQ[m] || (EqQ[a, 0] && NeQ[c, 0])))
 

rule 3502
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*sin[(e_.) 
+ (f_.)*(x_)] + (C_.)*sin[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(-C)*Co 
s[e + f*x]*((a + b*Sin[e + f*x])^(m + 1)/(b*f*(m + 2))), x] + Simp[1/(b*(m 
+ 2))   Int[(a + b*Sin[e + f*x])^m*Simp[A*b*(m + 2) + b*C*(m + 1) + (b*B*(m 
 + 2) - a*C)*Sin[e + f*x], x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] 
 &&  !LtQ[m, -1]
 
Maple [F]

\[\int \left (c \cos \left (f x +e \right )\right )^{m} \left (a +\cos \left (f x +e \right ) b \right )^{2} \left (A +B \cos \left (f x +e \right )\right )d x\]

Input:

int((c*cos(f*x+e))^m*(a+cos(f*x+e)*b)^2*(A+B*cos(f*x+e)),x)
 

Output:

int((c*cos(f*x+e))^m*(a+cos(f*x+e)*b)^2*(A+B*cos(f*x+e)),x)
 

Fricas [F]

\[ \int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx=\int { {\left (B \cos \left (f x + e\right ) + A\right )} {\left (b \cos \left (f x + e\right ) + a\right )}^{2} \left (c \cos \left (f x + e\right )\right )^{m} \,d x } \] Input:

integrate((c*cos(f*x+e))^m*(a+b*cos(f*x+e))^2*(A+B*cos(f*x+e)),x, algorith 
m="fricas")
 

Output:

integral((B*b^2*cos(f*x + e)^3 + A*a^2 + (2*B*a*b + A*b^2)*cos(f*x + e)^2 
+ (B*a^2 + 2*A*a*b)*cos(f*x + e))*(c*cos(f*x + e))^m, x)
 

Sympy [F(-1)]

Timed out. \[ \int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx=\text {Timed out} \] Input:

integrate((c*cos(f*x+e))**m*(a+b*cos(f*x+e))**2*(A+B*cos(f*x+e)),x)
 

Output:

Timed out
 

Maxima [F]

\[ \int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx=\int { {\left (B \cos \left (f x + e\right ) + A\right )} {\left (b \cos \left (f x + e\right ) + a\right )}^{2} \left (c \cos \left (f x + e\right )\right )^{m} \,d x } \] Input:

integrate((c*cos(f*x+e))^m*(a+b*cos(f*x+e))^2*(A+B*cos(f*x+e)),x, algorith 
m="maxima")
 

Output:

integrate((B*cos(f*x + e) + A)*(b*cos(f*x + e) + a)^2*(c*cos(f*x + e))^m, 
x)
 

Giac [F]

\[ \int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx=\int { {\left (B \cos \left (f x + e\right ) + A\right )} {\left (b \cos \left (f x + e\right ) + a\right )}^{2} \left (c \cos \left (f x + e\right )\right )^{m} \,d x } \] Input:

integrate((c*cos(f*x+e))^m*(a+b*cos(f*x+e))^2*(A+B*cos(f*x+e)),x, algorith 
m="giac")
 

Output:

integrate((B*cos(f*x + e) + A)*(b*cos(f*x + e) + a)^2*(c*cos(f*x + e))^m, 
x)
 

Mupad [F(-1)]

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

int((c*cos(e + f*x))^m*(A + B*cos(e + f*x))*(a + b*cos(e + f*x))^2,x)
 

Output:

int((c*cos(e + f*x))^m*(A + B*cos(e + f*x))*(a + b*cos(e + f*x))^2, x)
 

Reduce [F]

\[ \int (c \cos (e+f x))^m (a+b \cos (e+f x))^2 (A+B \cos (e+f x)) \, dx=c^{m} \left (\left (\int \cos \left (f x +e \right )^{m}d x \right ) a^{3}+3 \left (\int \cos \left (f x +e \right )^{m} \cos \left (f x +e \right )d x \right ) a^{2} b +\left (\int \cos \left (f x +e \right )^{m} \cos \left (f x +e \right )^{3}d x \right ) b^{3}+3 \left (\int \cos \left (f x +e \right )^{m} \cos \left (f x +e \right )^{2}d x \right ) a \,b^{2}\right ) \] Input:

int((c*cos(f*x+e))^m*(a+b*cos(f*x+e))^2*(A+B*cos(f*x+e)),x)
 

Output:

c**m*(int(cos(e + f*x)**m,x)*a**3 + 3*int(cos(e + f*x)**m*cos(e + f*x),x)* 
a**2*b + int(cos(e + f*x)**m*cos(e + f*x)**3,x)*b**3 + 3*int(cos(e + f*x)* 
*m*cos(e + f*x)**2,x)*a*b**2)