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

Optimal result
Mathematica [B] (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 = 29, antiderivative size = 73 \[ \int \cos (c+d x) (a+a \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=a^2 (2 A+B) x+\frac {a^2 (A+2 B) \text {arctanh}(\sin (c+d x))}{d}+\frac {a^2 (A-B) \sin (c+d x)}{d}+\frac {B \left (a^2+a^2 \sec (c+d x)\right ) \sin (c+d x)}{d} \] Output:

a^2*(2*A+B)*x+a^2*(A+2*B)*arctanh(sin(d*x+c))/d+a^2*(A-B)*sin(d*x+c)/d+B*( 
a^2+a^2*sec(d*x+c))*sin(d*x+c)/d
 

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(258\) vs. \(2(73)=146\).

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

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

Output:

(a^2*Cos[c + d*x]^3*Sec[(c + d*x)/2]^4*(1 + Sec[c + d*x])^2*(A + B*Sec[c + 
 d*x])*((2*A + B)*x - ((A + 2*B)*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]]) 
/d + ((A + 2*B)*Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]])/d + (A*Cos[d*x]* 
Sin[c])/d + (A*Cos[c]*Sin[d*x])/d + (B*Sin[(d*x)/2])/(d*(Cos[c/2] - Sin[c/ 
2])*(Cos[(c + d*x)/2] - Sin[(c + d*x)/2])) + (B*Sin[(d*x)/2])/(d*(Cos[c/2] 
 + Sin[c/2])*(Cos[(c + d*x)/2] + Sin[(c + d*x)/2]))))/(4*(B + A*Cos[c + d* 
x]))
 

Rubi [A] (verified)

Time = 0.43 (sec) , antiderivative size = 73, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.172, Rules used = {3042, 4506, 3042, 4484, 2009}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4506

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4484

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

\(\Big \downarrow \) 2009

\(\displaystyle \frac {a^2 (A+2 B) \text {arctanh}(\sin (c+d x))}{d}+\frac {a^2 (A-B) \sin (c+d x)}{d}+a^2 x (2 A+B)+\frac {B \sin (c+d x) \left (a^2 \sec (c+d x)+a^2\right )}{d}\)

Input:

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

Output:

a^2*(2*A + B)*x + (a^2*(A + 2*B)*ArcTanh[Sin[c + d*x]])/d + (a^2*(A - B)*S 
in[c + d*x])/d + (B*(a^2 + a^2*Sec[c + d*x])*Sin[c + d*x])/d
 

Defintions of rubi rules used

rule 2009
Int[u_, x_Symbol] :> Simp[IntSum[u, x], x] /; SumQ[u]
 

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

rule 4484
Int[(csc[(e_.) + (f_.)*(x_)]*(d_.))^(n_)*(csc[(e_.) + (f_.)*(x_)]*(b_.) + ( 
a_))*(csc[(e_.) + (f_.)*(x_)]*(B_.) + (A_)), x_Symbol] :> Simp[A*a*Cot[e + 
f*x]*((d*Csc[e + f*x])^n/(f*n)), x] + Simp[1/(d*n)   Int[(d*Csc[e + f*x])^( 
n + 1)*Simp[n*(B*a + A*b) + (B*b*n + A*a*(n + 1))*Csc[e + f*x], x], x], x] 
/; FreeQ[{a, b, d, e, f, A, B}, x] && NeQ[A*b - a*B, 0] && LeQ[n, -1]
 

rule 4506
Int[(csc[(e_.) + (f_.)*(x_)]*(d_.))^(n_)*(csc[(e_.) + (f_.)*(x_)]*(b_.) + ( 
a_))^(m_)*(csc[(e_.) + (f_.)*(x_)]*(B_.) + (A_)), x_Symbol] :> Simp[(-b)*B* 
Cot[e + f*x]*(a + b*Csc[e + f*x])^(m - 1)*((d*Csc[e + f*x])^n/(f*(m + n))), 
 x] + Simp[1/(d*(m + n))   Int[(a + b*Csc[e + f*x])^(m - 1)*(d*Csc[e + f*x] 
)^n*Simp[a*A*d*(m + n) + B*(b*d*n) + (A*b*d*(m + n) + a*B*d*(2*m + n - 1))* 
Csc[e + f*x], x], x], x] /; FreeQ[{a, b, d, e, f, A, B, n}, x] && NeQ[A*b - 
 a*B, 0] && EqQ[a^2 - b^2, 0] && GtQ[m, 1/2] &&  !LtQ[n, -1]
 
Maple [A] (verified)

Time = 0.43 (sec) , antiderivative size = 88, normalized size of antiderivative = 1.21

method result size
derivativedivides \(\frac {A \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+B \,a^{2} \tan \left (d x +c \right )+2 A \,a^{2} \left (d x +c \right )+2 B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+A \,a^{2} \sin \left (d x +c \right )+B \,a^{2} \left (d x +c \right )}{d}\) \(88\)
default \(\frac {A \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+B \,a^{2} \tan \left (d x +c \right )+2 A \,a^{2} \left (d x +c \right )+2 B \,a^{2} \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+A \,a^{2} \sin \left (d x +c \right )+B \,a^{2} \left (d x +c \right )}{d}\) \(88\)
parallelrisch \(-\frac {\left (\cos \left (d x +c \right ) \left (A +2 B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )-\cos \left (d x +c \right ) \left (A +2 B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )-\frac {A \sin \left (2 d x +2 c \right )}{2}-2 d \left (A +\frac {B}{2}\right ) x \cos \left (d x +c \right )-B \sin \left (d x +c \right )\right ) a^{2}}{\cos \left (d x +c \right ) d}\) \(103\)
risch \(2 a^{2} A x +a^{2} x B -\frac {i A \,a^{2} {\mathrm e}^{i \left (d x +c \right )}}{2 d}+\frac {i A \,a^{2} {\mathrm e}^{-i \left (d x +c \right )}}{2 d}+\frac {2 i B \,a^{2}}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A}{d}+\frac {2 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) B}{d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A}{d}-\frac {2 a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) B}{d}\) \(163\)
norman \(\frac {\left (2 A \,a^{2}+B \,a^{2}\right ) x +\left (-2 A \,a^{2}-B \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}+\left (-2 A \,a^{2}-B \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{4}+\left (2 A \,a^{2}+B \,a^{2}\right ) x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{6}-\frac {4 A \,a^{2} \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3}}{d}+\frac {2 a^{2} \left (A -B \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{5}}{d}+\frac {2 a^{2} \left (A +B \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}}{\left (1+\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}\right ) \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{2}-1\right )^{2}}+\frac {a^{2} \left (A +2 B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d}-\frac {a^{2} \left (A +2 B \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{d}\) \(238\)

Input:

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

Output:

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

Fricas [A] (verification not implemented)

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

integrate(cos(d*x+c)*(a+a*sec(d*x+c))^2*(A+B*sec(d*x+c)),x, algorithm="fri 
cas")
 

Output:

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

Sympy [F]

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

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

Output:

a**2*(Integral(A*cos(c + d*x), x) + Integral(2*A*cos(c + d*x)*sec(c + d*x) 
, x) + Integral(A*cos(c + d*x)*sec(c + d*x)**2, x) + Integral(B*cos(c + d* 
x)*sec(c + d*x), x) + Integral(2*B*cos(c + d*x)*sec(c + d*x)**2, x) + Inte 
gral(B*cos(c + d*x)*sec(c + d*x)**3, x))
 

Maxima [A] (verification not implemented)

Time = 0.03 (sec) , antiderivative size = 105, normalized size of antiderivative = 1.44 \[ \int \cos (c+d x) (a+a \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {4 \, {\left (d x + c\right )} A a^{2} + 2 \, {\left (d x + c\right )} B a^{2} + A 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 \, 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^{2} \sin \left (d x + c\right ) + 2 \, B a^{2} \tan \left (d x + c\right )}{2 \, d} \] Input:

integrate(cos(d*x+c)*(a+a*sec(d*x+c))^2*(A+B*sec(d*x+c)),x, algorithm="max 
ima")
 

Output:

1/2*(4*(d*x + c)*A*a^2 + 2*(d*x + c)*B*a^2 + A*a^2*(log(sin(d*x + c) + 1) 
- log(sin(d*x + c) - 1)) + 2*B*a^2*(log(sin(d*x + c) + 1) - log(sin(d*x + 
c) - 1)) + 2*A*a^2*sin(d*x + c) + 2*B*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. 157 vs. \(2 (73) = 146\).

Time = 0.16 (sec) , antiderivative size = 157, normalized size of antiderivative = 2.15 \[ \int \cos (c+d x) (a+a \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {{\left (2 \, A a^{2} + B a^{2}\right )} {\left (d x + c\right )} + {\left (A a^{2} + 2 \, B a^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - {\left (A a^{2} + 2 \, B a^{2}\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 a^{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 a^{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(cos(d*x+c)*(a+a*sec(d*x+c))^2*(A+B*sec(d*x+c)),x, algorithm="gia 
c")
 

Output:

((2*A*a^2 + B*a^2)*(d*x + c) + (A*a^2 + 2*B*a^2)*log(abs(tan(1/2*d*x + 1/2 
*c) + 1)) - (A*a^2 + 2*B*a^2)*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*a^2*tan(1/2*d*x + 1/2*c)^3 - A*a^2*tan(1/2*d* 
x + 1/2*c) - B*a^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 = 11.15 (sec) , antiderivative size = 161, normalized size of antiderivative = 2.21 \[ \int \cos (c+d x) (a+a \sec (c+d x))^2 (A+B \sec (c+d x)) \, dx=\frac {A\,a^2\,\sin \left (c+d\,x\right )}{d}+\frac {4\,A\,a^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 {2\,A\,a^2\,\mathrm {atanh}\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 {2\,B\,a^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 {4\,B\,a^2\,\mathrm {atanh}\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\,\sin \left (c+d\,x\right )}{d\,\cos \left (c+d\,x\right )} \] Input:

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

Output:

(A*a^2*sin(c + d*x))/d + (4*A*a^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/ 
2)))/d + (2*A*a^2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (2*B*a 
^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (4*B*a^2*atanh(sin(c/2 
 + (d*x)/2)/cos(c/2 + (d*x)/2)))/d + (B*a^2*sin(c + d*x))/(d*cos(c + d*x))
 

Reduce [B] (verification not implemented)

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

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

Output:

(a**2*( - cos(c + d*x)*log(tan((c + d*x)/2) - 1)*a - 2*cos(c + d*x)*log(ta 
n((c + d*x)/2) - 1)*b + cos(c + d*x)*log(tan((c + d*x)/2) + 1)*a + 2*cos(c 
 + d*x)*log(tan((c + d*x)/2) + 1)*b + cos(c + d*x)*sin(c + d*x)*a + 2*cos( 
c + d*x)*a*c + 2*cos(c + d*x)*a*d*x + cos(c + d*x)*b*c + cos(c + d*x)*b*d* 
x + sin(c + d*x)*b))/(cos(c + d*x)*d)