\(\int (a+b \cos (e+f x))^m (B \cos (e+f x)+C \cos ^2(e+f x)) \, dx\) [233]

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

Optimal result

Integrand size = 32, antiderivative size = 296 \[ \int (a+b \cos (e+f x))^m \left (B \cos (e+f x)+C \cos ^2(e+f x)\right ) \, dx=\frac {C (a+b \cos (e+f x))^{1+m} \sin (e+f x)}{b f (2+m)}-\frac {\sqrt {2} (a C-b B (2+m)) \operatorname {AppellF1}\left (\frac {1}{2},\frac {1}{2},-1-m,\frac {3}{2},\frac {1}{2} (1-\cos (e+f x)),\frac {b (1-\cos (e+f x))}{a+b}\right ) (a+b \cos (e+f x))^{1+m} \left (\frac {a+b \cos (e+f x)}{a+b}\right )^{-1-m} \sin (e+f x)}{b^2 f (2+m) \sqrt {1+\cos (e+f x)}}+\frac {\sqrt {2} \left (a^2 C+b^2 C (1+m)-a b B (2+m)\right ) \operatorname {AppellF1}\left (\frac {1}{2},\frac {1}{2},-m,\frac {3}{2},\frac {1}{2} (1-\cos (e+f x)),\frac {b (1-\cos (e+f x))}{a+b}\right ) (a+b \cos (e+f x))^m \left (\frac {a+b \cos (e+f x)}{a+b}\right )^{-m} \sin (e+f x)}{b^2 f (2+m) \sqrt {1+\cos (e+f x)}} \] Output:

C*(a+b*cos(f*x+e))^(1+m)*sin(f*x+e)/b/f/(2+m)-2^(1/2)*(a*C-b*B*(2+m))*Appe 
llF1(1/2,-1-m,1/2,3/2,b*(1-cos(f*x+e))/(a+b),1/2-1/2*cos(f*x+e))*(a+b*cos( 
f*x+e))^(1+m)*((a+b*cos(f*x+e))/(a+b))^(-1-m)*sin(f*x+e)/b^2/f/(2+m)/(1+co 
s(f*x+e))^(1/2)+2^(1/2)*(a^2*C+b^2*C*(1+m)-a*b*B*(2+m))*AppellF1(1/2,-m,1/ 
2,3/2,b*(1-cos(f*x+e))/(a+b),1/2-1/2*cos(f*x+e))*(a+b*cos(f*x+e))^m*sin(f* 
x+e)/b^2/f/(2+m)/(1+cos(f*x+e))^(1/2)/(((a+b*cos(f*x+e))/(a+b))^m)
 

Mathematica [B] (warning: unable to verify)

Leaf count is larger than twice the leaf count of optimal. \(13441\) vs. \(2(296)=592\).

Time = 28.38 (sec) , antiderivative size = 13441, normalized size of antiderivative = 45.41 \[ \int (a+b \cos (e+f x))^m \left (B \cos (e+f x)+C \cos ^2(e+f x)\right ) \, dx=\text {Result too large to show} \] Input:

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

Output:

Result too large to show
 

Rubi [A] (verified)

Time = 0.69 (sec) , antiderivative size = 295, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.250, Rules used = {3042, 3502, 3042, 3235, 3042, 3144, 156, 155}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3502

\(\displaystyle \frac {\int (a+b \cos (e+f x))^m (b C (m+1)-(a C-b B (m+2)) \cos (e+f x))dx}{b (m+2)}+\frac {C \sin (e+f x) (a+b \cos (e+f x))^{m+1}}{b f (m+2)}\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3235

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3144

\(\displaystyle \frac {\frac {\sin (e+f x) (a C-b B (m+2)) \int \frac {(a+b \cos (e+f x))^{m+1}}{\sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}d\cos (e+f x)}{b f \sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}-\frac {\sin (e+f x) \left (a^2 C-a b B (m+2)+b^2 C (m+1)\right ) \int \frac {(a+b \cos (e+f x))^m}{\sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}d\cos (e+f x)}{b f \sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}}{b (m+2)}+\frac {C \sin (e+f x) (a+b \cos (e+f x))^{m+1}}{b f (m+2)}\)

\(\Big \downarrow \) 156

\(\displaystyle \frac {\frac {(a+b) \sin (e+f x) (a C-b B (m+2)) (a+b \cos (e+f x))^m \left (\frac {a+b \cos (e+f x)}{a+b}\right )^{-m} \int \frac {\left (\frac {a}{a+b}+\frac {b \cos (e+f x)}{a+b}\right )^{m+1}}{\sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}d\cos (e+f x)}{b f \sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}-\frac {\sin (e+f x) \left (a^2 C-a b B (m+2)+b^2 C (m+1)\right ) (a+b \cos (e+f x))^m \left (\frac {a+b \cos (e+f x)}{a+b}\right )^{-m} \int \frac {\left (\frac {a}{a+b}+\frac {b \cos (e+f x)}{a+b}\right )^m}{\sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}d\cos (e+f x)}{b f \sqrt {1-\cos (e+f x)} \sqrt {\cos (e+f x)+1}}}{b (m+2)}+\frac {C \sin (e+f x) (a+b \cos (e+f x))^{m+1}}{b f (m+2)}\)

\(\Big \downarrow \) 155

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

Input:

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

Output:

(C*(a + b*Cos[e + f*x])^(1 + m)*Sin[e + f*x])/(b*f*(2 + m)) + (-((Sqrt[2]* 
(a + b)*(a*C - b*B*(2 + m))*AppellF1[1/2, 1/2, -1 - m, 3/2, (1 - Cos[e + f 
*x])/2, (b*(1 - Cos[e + f*x]))/(a + b)]*(a + b*Cos[e + f*x])^m*Sin[e + f*x 
])/(b*f*Sqrt[1 + Cos[e + f*x]]*((a + b*Cos[e + f*x])/(a + b))^m)) + (Sqrt[ 
2]*(a^2*C + b^2*C*(1 + m) - a*b*B*(2 + m))*AppellF1[1/2, 1/2, -m, 3/2, (1 
- Cos[e + f*x])/2, (b*(1 - Cos[e + f*x]))/(a + b)]*(a + b*Cos[e + f*x])^m* 
Sin[e + f*x])/(b*f*Sqrt[1 + Cos[e + f*x]]*((a + b*Cos[e + f*x])/(a + b))^m 
))/(b*(2 + m))
 

Defintions of rubi rules used

rule 155
Int[((a_) + (b_.)*(x_))^(m_)*((c_.) + (d_.)*(x_))^(n_)*((e_.) + (f_.)*(x_)) 
^(p_), x_] :> Simp[((a + b*x)^(m + 1)/(b*(m + 1)*Simplify[b/(b*c - a*d)]^n* 
Simplify[b/(b*e - a*f)]^p))*AppellF1[m + 1, -n, -p, m + 2, (-d)*((a + b*x)/ 
(b*c - a*d)), (-f)*((a + b*x)/(b*e - a*f))], x] /; FreeQ[{a, b, c, d, e, f, 
 m, n, p}, x] &&  !IntegerQ[m] &&  !IntegerQ[n] &&  !IntegerQ[p] && GtQ[Sim 
plify[b/(b*c - a*d)], 0] && GtQ[Simplify[b/(b*e - a*f)], 0] &&  !(GtQ[Simpl 
ify[d/(d*a - c*b)], 0] && GtQ[Simplify[d/(d*e - c*f)], 0] && SimplerQ[c + d 
*x, a + b*x]) &&  !(GtQ[Simplify[f/(f*a - e*b)], 0] && GtQ[Simplify[f/(f*c 
- e*d)], 0] && SimplerQ[e + f*x, a + b*x])
 

rule 156
Int[((a_) + (b_.)*(x_))^(m_)*((c_.) + (d_.)*(x_))^(n_)*((e_.) + (f_.)*(x_)) 
^(p_), x_] :> Simp[(e + f*x)^FracPart[p]/(Simplify[b/(b*e - a*f)]^IntPart[p 
]*(b*((e + f*x)/(b*e - a*f)))^FracPart[p])   Int[(a + b*x)^m*(c + d*x)^n*Si 
mp[b*(e/(b*e - a*f)) + b*f*(x/(b*e - a*f)), x]^p, x], x] /; FreeQ[{a, b, c, 
 d, e, f, m, n, p}, x] &&  !IntegerQ[m] &&  !IntegerQ[n] &&  !IntegerQ[p] & 
& GtQ[Simplify[b/(b*c - a*d)], 0] &&  !GtQ[Simplify[b/(b*e - a*f)], 0]
 

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

rule 3144
Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[Cos[c + 
d*x]/(d*Sqrt[1 + Sin[c + d*x]]*Sqrt[1 - Sin[c + d*x]])   Subst[Int[(a + b*x 
)^n/(Sqrt[1 + x]*Sqrt[1 - x]), x], x, Sin[c + d*x]], x] /; FreeQ[{a, b, c, 
d, n}, x] && NeQ[a^2 - b^2, 0] &&  !IntegerQ[2*n]
 

rule 3235
Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*sin[(e_.) + 
(f_.)*(x_)]), x_Symbol] :> Simp[(b*c - a*d)/b   Int[(a + b*Sin[e + f*x])^m, 
 x], x] + Simp[d/b   Int[(a + b*Sin[e + f*x])^(m + 1), x], x] /; FreeQ[{a, 
b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 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 (a +b \cos \left (f x +e \right )\right )^{m} \left (B \cos \left (f x +e \right )+C \cos \left (f x +e \right )^{2}\right )d x\]

Input:

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

Output:

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

Fricas [F]

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

integrate((a+b*cos(f*x+e))^m*(B*cos(f*x+e)+C*cos(f*x+e)^2),x, algorithm="f 
ricas")
 

Output:

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

Sympy [F(-1)]

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

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

Output:

Timed out
 

Maxima [F]

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

integrate((a+b*cos(f*x+e))^m*(B*cos(f*x+e)+C*cos(f*x+e)^2),x, algorithm="m 
axima")
 

Output:

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

Giac [F]

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

integrate((a+b*cos(f*x+e))^m*(B*cos(f*x+e)+C*cos(f*x+e)^2),x, algorithm="g 
iac")
 

Output:

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

Mupad [F(-1)]

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

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

Output:

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

Reduce [F]

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

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

Output:

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