\(\int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx\) [227]

Optimal result
Mathematica [A] (verified)
Rubi [A] (verified)
Maple [A] (verified)
Fricas [A] (verification not implemented)
Sympy [F]
Maxima [A] (verification not implemented)
Giac [B] (verification not implemented)
Mupad [B] (verification not implemented)
Reduce [B] (verification not implemented)

Optimal result

Integrand size = 31, antiderivative size = 60 \[ \int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx=b (A b+2 a B) x+\frac {a (2 A b+a B) \text {arctanh}(\sin (c+d x))}{d}+\frac {b^2 B \sin (c+d x)}{d}+\frac {a^2 A \tan (c+d x)}{d} \] Output:

b*(A*b+2*B*a)*x+a*(2*A*b+B*a)*arctanh(sin(d*x+c))/d+b^2*B*sin(d*x+c)/d+a^2 
*A*tan(d*x+c)/d
 

Mathematica [A] (verified)

Time = 2.14 (sec) , antiderivative size = 109, normalized size of antiderivative = 1.82 \[ \int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx=\frac {b (A b+2 a B) (c+d x)-a (2 A b+a B) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+a (2 A b+a B) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )+b^2 B \sin (c+d x)+a^2 A \tan (c+d x)}{d} \] Input:

Integrate[(a + b*Cos[c + d*x])^2*(A + B*Cos[c + d*x])*Sec[c + d*x]^2,x]
 

Output:

(b*(A*b + 2*a*B)*(c + d*x) - a*(2*A*b + a*B)*Log[Cos[(c + d*x)/2] - Sin[(c 
 + d*x)/2]] + a*(2*A*b + a*B)*Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]] + b 
^2*B*Sin[c + d*x] + a^2*A*Tan[c + d*x])/d
 

Rubi [A] (verified)

Time = 0.57 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.290, Rules used = {3042, 3467, 25, 3042, 3502, 3042, 3214, 3042, 4257}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3467

\(\displaystyle \frac {a^2 A \tan (c+d x)}{d}-\int -\left (\left (b^2 B \cos ^2(c+d x)+b (A b+2 a B) \cos (c+d x)+a (2 A b+a B)\right ) \sec (c+d x)\right )dx\)

\(\Big \downarrow \) 25

\(\displaystyle \int \left (b^2 B \cos ^2(c+d x)+b (A b+2 a B) \cos (c+d x)+a (2 A b+a B)\right ) \sec (c+d x)dx+\frac {a^2 A \tan (c+d x)}{d}\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3502

\(\displaystyle \int (a (2 A b+a B)+b (A b+2 a B) \cos (c+d x)) \sec (c+d x)dx+\frac {a^2 A \tan (c+d x)}{d}+\frac {b^2 B \sin (c+d x)}{d}\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3214

\(\displaystyle a (a B+2 A b) \int \sec (c+d x)dx+\frac {a^2 A \tan (c+d x)}{d}+b x (2 a B+A b)+\frac {b^2 B \sin (c+d x)}{d}\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4257

\(\displaystyle \frac {a^2 A \tan (c+d x)}{d}+\frac {a (a B+2 A b) \text {arctanh}(\sin (c+d x))}{d}+b x (2 a B+A b)+\frac {b^2 B \sin (c+d x)}{d}\)

Input:

Int[(a + b*Cos[c + d*x])^2*(A + B*Cos[c + d*x])*Sec[c + d*x]^2,x]
 

Output:

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

Defintions of rubi rules used

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

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

rule 3214
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[b*(x/d), x] - Simp[(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 3467
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^2*((A_.) + (B_.)*sin[(e_.) + (f 
_.)*(x_)])*((c_.) + (d_.)*sin[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[ 
(B*c - A*d)*(b*c - a*d)^2*Cos[e + f*x]*((c + d*Sin[e + f*x])^(n + 1)/(f*d^2 
*(n + 1)*(c^2 - d^2))), x] - Simp[1/(d^2*(n + 1)*(c^2 - d^2))   Int[(c + d* 
Sin[e + f*x])^(n + 1)*Simp[d*(n + 1)*(B*(b*c - a*d)^2 - A*d*(a^2*c + b^2*c 
- 2*a*b*d)) - ((B*c - A*d)*(a^2*d^2*(n + 2) + b^2*(c^2 + d^2*(n + 1))) + 2* 
a*b*d*(A*c*d*(n + 2) - B*(c^2 + d^2*(n + 1))))*Sin[e + f*x] - b^2*B*d*(n + 
1)*(c^2 - d^2)*Sin[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B} 
, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 - b^2, 0] && NeQ[c^2 - d^2, 0] && LtQ[ 
n, -1]
 

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]
 

rule 4257
Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] 
 /; FreeQ[{c, d}, x]
 
Maple [A] (verified)

Time = 4.46 (sec) , antiderivative size = 79, normalized size of antiderivative = 1.32

method result size
parts \(\frac {a^{2} A \tan \left (d x +c \right )}{d}+\frac {\left (A \,b^{2}+2 B a b \right ) \left (d x +c \right )}{d}+\frac {\left (2 A a b +a^{2} B \right ) \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{d}+\frac {b^{2} B \sin \left (d x +c \right )}{d}\) \(79\)
derivativedivides \(\frac {A \tan \left (d x +c \right ) a^{2}+a^{2} B \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 A a b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 B a b \left (d x +c \right )+A \,b^{2} \left (d x +c \right )+B \sin \left (d x +c \right ) b^{2}}{d}\) \(86\)
default \(\frac {A \tan \left (d x +c \right ) a^{2}+a^{2} B \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 A a b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 B a b \left (d x +c \right )+A \,b^{2} \left (d x +c \right )+B \sin \left (d x +c \right ) b^{2}}{d}\) \(86\)
parallelrisch \(\frac {\left (-4 A a b -2 a^{2} B \right ) \cos \left (d x +c \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )+\left (4 A a b +2 a^{2} B \right ) \cos \left (d x +c \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )+B \sin \left (2 d x +2 c \right ) b^{2}+2 b d x \left (A b +2 B a \right ) \cos \left (d x +c \right )+2 a^{2} A \sin \left (d x +c \right )}{2 \cos \left (d x +c \right ) d}\) \(122\)
risch \(x A \,b^{2}+2 x B a b -\frac {i B \,b^{2} {\mathrm e}^{i \left (d x +c \right )}}{2 d}+\frac {i B \,b^{2} {\mathrm e}^{-i \left (d x +c \right )}}{2 d}+\frac {2 i a^{2} A}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}-\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A b}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B}{d}+\frac {2 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A b}{d}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B}{d}\) \(160\)
norman \(\frac {\left (-A \,b^{2}-2 B a b \right ) x +\left (-2 A \,b^{2}-4 B a b \right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}+\left (A \,b^{2}+2 B a b \right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{8}+\left (2 A \,b^{2}+4 B a b \right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{6}-\frac {2 \left (a^{2} A -B \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{7}}{d}-\frac {2 \left (a^{2} A +B \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}-\frac {2 \left (3 a^{2} A -B \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{5}}{d}-\frac {2 \left (3 a^{2} A +B \,b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{d}}{\left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right )^{3} \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )}+\frac {a \left (2 A b +B a \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d}-\frac {a \left (2 A b +B a \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{d}\) \(283\)

Input:

int((a+cos(d*x+c)*b)^2*(A+B*cos(d*x+c))*sec(d*x+c)^2,x,method=_RETURNVERBO 
SE)
 

Output:

a^2*A*tan(d*x+c)/d+(A*b^2+2*B*a*b)/d*(d*x+c)+(2*A*a*b+B*a^2)/d*ln(sec(d*x+ 
c)+tan(d*x+c))+b^2*B*sin(d*x+c)/d
 

Fricas [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 117, normalized size of antiderivative = 1.95 \[ \int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx=\frac {2 \, {\left (2 \, B a b + A b^{2}\right )} d x \cos \left (d x + c\right ) + {\left (B a^{2} + 2 \, A a b\right )} \cos \left (d x + c\right ) \log \left (\sin \left (d x + c\right ) + 1\right ) - {\left (B a^{2} + 2 \, A a b\right )} \cos \left (d x + c\right ) \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (B b^{2} \cos \left (d x + c\right ) + A a^{2}\right )} \sin \left (d x + c\right )}{2 \, d \cos \left (d x + c\right )} \] Input:

integrate((a+b*cos(d*x+c))^2*(A+B*cos(d*x+c))*sec(d*x+c)^2,x, algorithm="f 
ricas")
 

Output:

1/2*(2*(2*B*a*b + A*b^2)*d*x*cos(d*x + c) + (B*a^2 + 2*A*a*b)*cos(d*x + c) 
*log(sin(d*x + c) + 1) - (B*a^2 + 2*A*a*b)*cos(d*x + c)*log(-sin(d*x + c) 
+ 1) + 2*(B*b^2*cos(d*x + c) + A*a^2)*sin(d*x + c))/(d*cos(d*x + c))
 

Sympy [F]

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

integrate((a+b*cos(d*x+c))**2*(A+B*cos(d*x+c))*sec(d*x+c)**2,x)
 

Output:

Integral((A + B*cos(c + d*x))*(a + b*cos(c + d*x))**2*sec(c + d*x)**2, x)
 

Maxima [A] (verification not implemented)

Time = 0.04 (sec) , antiderivative size = 103, normalized size of antiderivative = 1.72 \[ \int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx=\frac {4 \, {\left (d x + c\right )} B a b + 2 \, {\left (d x + c\right )} A b^{2} + B a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 2 \, A a b {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 2 \, B b^{2} \sin \left (d x + c\right ) + 2 \, A a^{2} \tan \left (d x + c\right )}{2 \, d} \] Input:

integrate((a+b*cos(d*x+c))^2*(A+B*cos(d*x+c))*sec(d*x+c)^2,x, algorithm="m 
axima")
 

Output:

1/2*(4*(d*x + c)*B*a*b + 2*(d*x + c)*A*b^2 + B*a^2*(log(sin(d*x + c) + 1) 
- log(sin(d*x + c) - 1)) + 2*A*a*b*(log(sin(d*x + c) + 1) - log(sin(d*x + 
c) - 1)) + 2*B*b^2*sin(d*x + c) + 2*A*a^2*tan(d*x + c))/d
 

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 152 vs. \(2 (60) = 120\).

Time = 0.17 (sec) , antiderivative size = 152, normalized size of antiderivative = 2.53 \[ \int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx=\frac {{\left (2 \, B a b + A b^{2}\right )} {\left (d x + c\right )} + {\left (B a^{2} + 2 \, A a b\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - {\left (B a^{2} + 2 \, A a b\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - \frac {2 \, {\left (A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + A a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - 1}}{d} \] Input:

integrate((a+b*cos(d*x+c))^2*(A+B*cos(d*x+c))*sec(d*x+c)^2,x, algorithm="g 
iac")
 

Output:

((2*B*a*b + A*b^2)*(d*x + c) + (B*a^2 + 2*A*a*b)*log(abs(tan(1/2*d*x + 1/2 
*c) + 1)) - (B*a^2 + 2*A*a*b)*log(abs(tan(1/2*d*x + 1/2*c) - 1)) - 2*(A*a^ 
2*tan(1/2*d*x + 1/2*c)^3 - B*b^2*tan(1/2*d*x + 1/2*c)^3 + A*a^2*tan(1/2*d* 
x + 1/2*c) + B*b^2*tan(1/2*d*x + 1/2*c))/(tan(1/2*d*x + 1/2*c)^4 - 1))/d
 

Mupad [B] (verification not implemented)

Time = 42.43 (sec) , antiderivative size = 169, normalized size of antiderivative = 2.82 \[ \int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx=\frac {A\,a^2\,\mathrm {tan}\left (c+d\,x\right )}{d}+\frac {2\,A\,b^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {B\,b^2\,\sin \left (2\,c+2\,d\,x\right )}{2\,d\,\cos \left (c+d\,x\right )}+\frac {4\,B\,a\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}-\frac {B\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,2{}\mathrm {i}}{d}-\frac {A\,a\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )\,1{}\mathrm {i}}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,4{}\mathrm {i}}{d} \] Input:

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

Output:

(A*a^2*tan(c + d*x))/d + (2*A*b^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/ 
2)))/d - (B*a^2*atan((sin(c/2 + (d*x)/2)*1i)/cos(c/2 + (d*x)/2))*2i)/d + ( 
B*b^2*sin(2*c + 2*d*x))/(2*d*cos(c + d*x)) - (A*a*b*atan((sin(c/2 + (d*x)/ 
2)*1i)/cos(c/2 + (d*x)/2))*4i)/d + (4*B*a*b*atan(sin(c/2 + (d*x)/2)/cos(c/ 
2 + (d*x)/2)))/d
 

Reduce [B] (verification not implemented)

Time = 0.18 (sec) , antiderivative size = 101, normalized size of antiderivative = 1.68 \[ \int (a+b \cos (c+d x))^2 (A+B \cos (c+d x)) \sec ^2(c+d x) \, dx=\frac {-3 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) a^{2} b +3 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) a^{2} b +\cos \left (d x +c \right ) \sin \left (d x +c \right ) b^{3}+3 \cos \left (d x +c \right ) a \,b^{2} d x +\sin \left (d x +c \right ) a^{3}}{\cos \left (d x +c \right ) d} \] Input:

int((a+b*cos(d*x+c))^2*(A+B*cos(d*x+c))*sec(d*x+c)^2,x)
 

Output:

( - 3*cos(c + d*x)*log(tan((c + d*x)/2) - 1)*a**2*b + 3*cos(c + d*x)*log(t 
an((c + d*x)/2) + 1)*a**2*b + cos(c + d*x)*sin(c + d*x)*b**3 + 3*cos(c + d 
*x)*a*b**2*d*x + sin(c + d*x)*a**3)/(cos(c + d*x)*d)