\(\int (c+d x) (a+a \sec (e+f x))^2 \, dx\) [8]

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

Optimal result

Integrand size = 18, antiderivative size = 134 \[ \int (c+d x) (a+a \sec (e+f x))^2 \, dx=\frac {a^2 (c+d x)^2}{2 d}-\frac {4 i a^2 (c+d x) \arctan \left (e^{i (e+f x)}\right )}{f}+\frac {a^2 d \log (\cos (e+f x))}{f^2}+\frac {2 i a^2 d \operatorname {PolyLog}\left (2,-i e^{i (e+f x)}\right )}{f^2}-\frac {2 i a^2 d \operatorname {PolyLog}\left (2,i e^{i (e+f x)}\right )}{f^2}+\frac {a^2 (c+d x) \tan (e+f x)}{f} \] Output:

1/2*a^2*(d*x+c)^2/d-4*I*a^2*(d*x+c)*arctan(exp(I*(f*x+e)))/f+a^2*d*ln(cos( 
f*x+e))/f^2+2*I*a^2*d*polylog(2,-I*exp(I*(f*x+e)))/f^2-2*I*a^2*d*polylog(2 
,I*exp(I*(f*x+e)))/f^2+a^2*(d*x+c)*tan(f*x+e)/f
 

Mathematica [A] (verified)

Time = 0.73 (sec) , antiderivative size = 123, normalized size of antiderivative = 0.92 \[ \int (c+d x) (a+a \sec (e+f x))^2 \, dx=\frac {a^2 \left (f^2 (c+d x)^2-8 i d f (c+d x) \arctan \left (e^{i (e+f x)}\right )+2 d^2 \log (\cos (e+f x))+4 i d^2 \operatorname {PolyLog}\left (2,-i e^{i (e+f x)}\right )-4 i d^2 \operatorname {PolyLog}\left (2,i e^{i (e+f x)}\right )+2 d f (c+d x) \tan (e+f x)\right )}{2 d f^2} \] Input:

Integrate[(c + d*x)*(a + a*Sec[e + f*x])^2,x]
 

Output:

(a^2*(f^2*(c + d*x)^2 - (8*I)*d*f*(c + d*x)*ArcTan[E^(I*(e + f*x))] + 2*d^ 
2*Log[Cos[e + f*x]] + (4*I)*d^2*PolyLog[2, (-I)*E^(I*(e + f*x))] - (4*I)*d 
^2*PolyLog[2, I*E^(I*(e + f*x))] + 2*d*f*(c + d*x)*Tan[e + f*x]))/(2*d*f^2 
)
 

Rubi [A] (verified)

Time = 0.34 (sec) , antiderivative size = 134, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.167, Rules used = {3042, 4678, 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 (c+d x) (a \sec (e+f x)+a)^2 \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4678

\(\displaystyle \int \left (a^2 (c+d x) \sec ^2(e+f x)+2 a^2 (c+d x) \sec (e+f x)+a^2 (c+d x)\right )dx\)

\(\Big \downarrow \) 2009

\(\displaystyle -\frac {4 i a^2 (c+d x) \arctan \left (e^{i (e+f x)}\right )}{f}+\frac {a^2 (c+d x) \tan (e+f x)}{f}+\frac {a^2 (c+d x)^2}{2 d}+\frac {2 i a^2 d \operatorname {PolyLog}\left (2,-i e^{i (e+f x)}\right )}{f^2}-\frac {2 i a^2 d \operatorname {PolyLog}\left (2,i e^{i (e+f x)}\right )}{f^2}+\frac {a^2 d \log (\cos (e+f x))}{f^2}\)

Input:

Int[(c + d*x)*(a + a*Sec[e + f*x])^2,x]
 

Output:

(a^2*(c + d*x)^2)/(2*d) - ((4*I)*a^2*(c + d*x)*ArcTan[E^(I*(e + f*x))])/f 
+ (a^2*d*Log[Cos[e + f*x]])/f^2 + ((2*I)*a^2*d*PolyLog[2, (-I)*E^(I*(e + f 
*x))])/f^2 - ((2*I)*a^2*d*PolyLog[2, I*E^(I*(e + f*x))])/f^2 + (a^2*(c + d 
*x)*Tan[e + f*x])/f
 

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 4678
Int[(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(n_.)*((c_.) + (d_.)*(x_))^(m_.) 
, x_Symbol] :> Int[ExpandIntegrand[(c + d*x)^m, (a + b*Csc[e + f*x])^n, x], 
 x] /; FreeQ[{a, b, c, d, e, f, m}, x] && IGtQ[m, 0] && IGtQ[n, 0]
 
Maple [A] (verified)

Time = 0.09 (sec) , antiderivative size = 191, normalized size of antiderivative = 1.43

method result size
parts \(a^{2} \left (\frac {1}{2} d \,x^{2}+c x \right )+\frac {a^{2} d \tan \left (f x +e \right ) x}{f}+\frac {a^{2} d \ln \left (\cos \left (f x +e \right )\right )}{f^{2}}+\frac {a^{2} c \tan \left (f x +e \right )}{f}+\frac {2 a^{2} \left (\frac {d \left (-\left (f x +e \right ) \ln \left (1+i {\mathrm e}^{i \left (f x +e \right )}\right )+\left (f x +e \right ) \ln \left (1-i {\mathrm e}^{i \left (f x +e \right )}\right )+i \operatorname {dilog}\left (1+i {\mathrm e}^{i \left (f x +e \right )}\right )-i \operatorname {dilog}\left (1-i {\mathrm e}^{i \left (f x +e \right )}\right )\right )}{f}+c \ln \left (\sec \left (f x +e \right )+\tan \left (f x +e \right )\right )-\frac {e d \ln \left (\sec \left (f x +e \right )+\tan \left (f x +e \right )\right )}{f}\right )}{f}\) \(191\)
derivativedivides \(\frac {a^{2} c \left (f x +e \right )-\frac {a^{2} d e \left (f x +e \right )}{f}+\frac {a^{2} d \left (f x +e \right )^{2}}{2 f}+2 a^{2} c \ln \left (\sec \left (f x +e \right )+\tan \left (f x +e \right )\right )-\frac {2 a^{2} d e \ln \left (\sec \left (f x +e \right )+\tan \left (f x +e \right )\right )}{f}+\frac {2 a^{2} d \left (-\left (f x +e \right ) \ln \left (1+i {\mathrm e}^{i \left (f x +e \right )}\right )+\left (f x +e \right ) \ln \left (1-i {\mathrm e}^{i \left (f x +e \right )}\right )+i \operatorname {dilog}\left (1+i {\mathrm e}^{i \left (f x +e \right )}\right )-i \operatorname {dilog}\left (1-i {\mathrm e}^{i \left (f x +e \right )}\right )\right )}{f}+a^{2} c \tan \left (f x +e \right )-\frac {a^{2} d e \tan \left (f x +e \right )}{f}+\frac {a^{2} d \left (\left (f x +e \right ) \tan \left (f x +e \right )+\ln \left (\cos \left (f x +e \right )\right )\right )}{f}}{f}\) \(235\)
default \(\frac {a^{2} c \left (f x +e \right )-\frac {a^{2} d e \left (f x +e \right )}{f}+\frac {a^{2} d \left (f x +e \right )^{2}}{2 f}+2 a^{2} c \ln \left (\sec \left (f x +e \right )+\tan \left (f x +e \right )\right )-\frac {2 a^{2} d e \ln \left (\sec \left (f x +e \right )+\tan \left (f x +e \right )\right )}{f}+\frac {2 a^{2} d \left (-\left (f x +e \right ) \ln \left (1+i {\mathrm e}^{i \left (f x +e \right )}\right )+\left (f x +e \right ) \ln \left (1-i {\mathrm e}^{i \left (f x +e \right )}\right )+i \operatorname {dilog}\left (1+i {\mathrm e}^{i \left (f x +e \right )}\right )-i \operatorname {dilog}\left (1-i {\mathrm e}^{i \left (f x +e \right )}\right )\right )}{f}+a^{2} c \tan \left (f x +e \right )-\frac {a^{2} d e \tan \left (f x +e \right )}{f}+\frac {a^{2} d \left (\left (f x +e \right ) \tan \left (f x +e \right )+\ln \left (\cos \left (f x +e \right )\right )\right )}{f}}{f}\) \(235\)
risch \(\frac {a^{2} d \,x^{2}}{2}+a^{2} c x +\frac {2 i a^{2} \left (d x +c \right )}{f \left (1+{\mathrm e}^{2 i \left (f x +e \right )}\right )}+\frac {a^{2} d \ln \left (1+{\mathrm e}^{2 i \left (f x +e \right )}\right )}{f^{2}}-\frac {2 a^{2} d \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}-\frac {4 i a^{2} c \arctan \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f}+\frac {4 i a^{2} d e \arctan \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}-\frac {2 a^{2} d \ln \left (1+i {\mathrm e}^{i \left (f x +e \right )}\right ) x}{f}-\frac {2 a^{2} d \ln \left (1+i {\mathrm e}^{i \left (f x +e \right )}\right ) e}{f^{2}}+\frac {2 a^{2} d \ln \left (1-i {\mathrm e}^{i \left (f x +e \right )}\right ) x}{f}+\frac {2 a^{2} d \ln \left (1-i {\mathrm e}^{i \left (f x +e \right )}\right ) e}{f^{2}}+\frac {2 i a^{2} d \operatorname {dilog}\left (1+i {\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}-\frac {2 i a^{2} d \operatorname {dilog}\left (1-i {\mathrm e}^{i \left (f x +e \right )}\right )}{f^{2}}\) \(274\)

Input:

int((d*x+c)*(a+a*sec(f*x+e))^2,x,method=_RETURNVERBOSE)
 

Output:

a^2*(1/2*d*x^2+c*x)+a^2/f*d*tan(f*x+e)*x+a^2*d*ln(cos(f*x+e))/f^2+a^2/f*c* 
tan(f*x+e)+2*a^2/f*(1/f*d*(-(f*x+e)*ln(1+I*exp(I*(f*x+e)))+(f*x+e)*ln(1-I* 
exp(I*(f*x+e)))+I*dilog(1+I*exp(I*(f*x+e)))-I*dilog(1-I*exp(I*(f*x+e))))+c 
*ln(sec(f*x+e)+tan(f*x+e))-e/f*d*ln(sec(f*x+e)+tan(f*x+e)))
 

Fricas [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 525 vs. \(2 (114) = 228\).

Time = 0.11 (sec) , antiderivative size = 525, normalized size of antiderivative = 3.92 \[ \int (c+d x) (a+a \sec (e+f x))^2 \, dx=\frac {-2 i \, a^{2} d \cos \left (f x + e\right ) {\rm Li}_2\left (i \, \cos \left (f x + e\right ) + \sin \left (f x + e\right )\right ) - 2 i \, a^{2} d \cos \left (f x + e\right ) {\rm Li}_2\left (i \, \cos \left (f x + e\right ) - \sin \left (f x + e\right )\right ) + 2 i \, a^{2} d \cos \left (f x + e\right ) {\rm Li}_2\left (-i \, \cos \left (f x + e\right ) + \sin \left (f x + e\right )\right ) + 2 i \, a^{2} d \cos \left (f x + e\right ) {\rm Li}_2\left (-i \, \cos \left (f x + e\right ) - \sin \left (f x + e\right )\right ) - {\left (2 \, a^{2} d e - 2 \, a^{2} c f - a^{2} d\right )} \cos \left (f x + e\right ) \log \left (\cos \left (f x + e\right ) + i \, \sin \left (f x + e\right ) + i\right ) + {\left (2 \, a^{2} d e - 2 \, a^{2} c f + a^{2} d\right )} \cos \left (f x + e\right ) \log \left (\cos \left (f x + e\right ) - i \, \sin \left (f x + e\right ) + i\right ) + 2 \, {\left (a^{2} d f x + a^{2} d e\right )} \cos \left (f x + e\right ) \log \left (i \, \cos \left (f x + e\right ) + \sin \left (f x + e\right ) + 1\right ) - 2 \, {\left (a^{2} d f x + a^{2} d e\right )} \cos \left (f x + e\right ) \log \left (i \, \cos \left (f x + e\right ) - \sin \left (f x + e\right ) + 1\right ) + 2 \, {\left (a^{2} d f x + a^{2} d e\right )} \cos \left (f x + e\right ) \log \left (-i \, \cos \left (f x + e\right ) + \sin \left (f x + e\right ) + 1\right ) - 2 \, {\left (a^{2} d f x + a^{2} d e\right )} \cos \left (f x + e\right ) \log \left (-i \, \cos \left (f x + e\right ) - \sin \left (f x + e\right ) + 1\right ) - {\left (2 \, a^{2} d e - 2 \, a^{2} c f - a^{2} d\right )} \cos \left (f x + e\right ) \log \left (-\cos \left (f x + e\right ) + i \, \sin \left (f x + e\right ) + i\right ) + {\left (2 \, a^{2} d e - 2 \, a^{2} c f + a^{2} d\right )} \cos \left (f x + e\right ) \log \left (-\cos \left (f x + e\right ) - i \, \sin \left (f x + e\right ) + i\right ) + {\left (a^{2} d f^{2} x^{2} + 2 \, a^{2} c f^{2} x\right )} \cos \left (f x + e\right ) + 2 \, {\left (a^{2} d f x + a^{2} c f\right )} \sin \left (f x + e\right )}{2 \, f^{2} \cos \left (f x + e\right )} \] Input:

integrate((d*x+c)*(a+a*sec(f*x+e))^2,x, algorithm="fricas")
 

Output:

1/2*(-2*I*a^2*d*cos(f*x + e)*dilog(I*cos(f*x + e) + sin(f*x + e)) - 2*I*a^ 
2*d*cos(f*x + e)*dilog(I*cos(f*x + e) - sin(f*x + e)) + 2*I*a^2*d*cos(f*x 
+ e)*dilog(-I*cos(f*x + e) + sin(f*x + e)) + 2*I*a^2*d*cos(f*x + e)*dilog( 
-I*cos(f*x + e) - sin(f*x + e)) - (2*a^2*d*e - 2*a^2*c*f - a^2*d)*cos(f*x 
+ e)*log(cos(f*x + e) + I*sin(f*x + e) + I) + (2*a^2*d*e - 2*a^2*c*f + a^2 
*d)*cos(f*x + e)*log(cos(f*x + e) - I*sin(f*x + e) + I) + 2*(a^2*d*f*x + a 
^2*d*e)*cos(f*x + e)*log(I*cos(f*x + e) + sin(f*x + e) + 1) - 2*(a^2*d*f*x 
 + a^2*d*e)*cos(f*x + e)*log(I*cos(f*x + e) - sin(f*x + e) + 1) + 2*(a^2*d 
*f*x + a^2*d*e)*cos(f*x + e)*log(-I*cos(f*x + e) + sin(f*x + e) + 1) - 2*( 
a^2*d*f*x + a^2*d*e)*cos(f*x + e)*log(-I*cos(f*x + e) - sin(f*x + e) + 1) 
- (2*a^2*d*e - 2*a^2*c*f - a^2*d)*cos(f*x + e)*log(-cos(f*x + e) + I*sin(f 
*x + e) + I) + (2*a^2*d*e - 2*a^2*c*f + a^2*d)*cos(f*x + e)*log(-cos(f*x + 
 e) - I*sin(f*x + e) + I) + (a^2*d*f^2*x^2 + 2*a^2*c*f^2*x)*cos(f*x + e) + 
 2*(a^2*d*f*x + a^2*c*f)*sin(f*x + e))/(f^2*cos(f*x + e))
                                                                                    
                                                                                    
 

Sympy [F]

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

integrate((d*x+c)*(a+a*sec(f*x+e))**2,x)
 

Output:

a**2*(Integral(c, x) + Integral(2*c*sec(e + f*x), x) + Integral(c*sec(e + 
f*x)**2, x) + Integral(d*x, x) + Integral(2*d*x*sec(e + f*x), x) + Integra 
l(d*x*sec(e + f*x)**2, x))
 

Maxima [F]

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

integrate((d*x+c)*(a+a*sec(f*x+e))^2,x, algorithm="maxima")
 

Output:

1/2*(a^2*d*f^2*x^2 + 2*a^2*c*f^2*x + (a^2*d*f^2*x^2 + 2*a^2*c*f^2*x)*cos(2 
*f*x + 2*e)^2 + (a^2*d*f^2*x^2 + 2*a^2*c*f^2*x)*sin(2*f*x + 2*e)^2 + 2*(a^ 
2*d*f^2*x^2 + 2*a^2*c*f^2*x)*cos(2*f*x + 2*e) + 8*(a^2*d*f^3*cos(2*f*x + 2 
*e)^2 + a^2*d*f^3*sin(2*f*x + 2*e)^2 + 2*a^2*d*f^3*cos(2*f*x + 2*e) + a^2* 
d*f^3)*integrate((x*cos(2*f*x + 2*e)*cos(f*x + e) + x*sin(2*f*x + 2*e)*sin 
(f*x + e) + x*cos(f*x + e))/(f*cos(2*f*x + 2*e)^2 + f*sin(2*f*x + 2*e)^2 + 
 2*f*cos(2*f*x + 2*e) + f), x) + (a^2*d*cos(2*f*x + 2*e)^2 + a^2*d*sin(2*f 
*x + 2*e)^2 + 2*a^2*d*cos(2*f*x + 2*e) + a^2*d)*log(cos(2*f*x + 2*e)^2 + s 
in(2*f*x + 2*e)^2 + 2*cos(2*f*x + 2*e) + 1) + 2*(a^2*c*f*cos(2*f*x + 2*e)^ 
2 + a^2*c*f*sin(2*f*x + 2*e)^2 + 2*a^2*c*f*cos(2*f*x + 2*e) + a^2*c*f)*log 
(cos(f*x + e)^2 + sin(f*x + e)^2 + 2*sin(f*x + e) + 1) - 2*(a^2*c*f*cos(2* 
f*x + 2*e)^2 + a^2*c*f*sin(2*f*x + 2*e)^2 + 2*a^2*c*f*cos(2*f*x + 2*e) + a 
^2*c*f)*log(cos(f*x + e)^2 + sin(f*x + e)^2 - 2*sin(f*x + e) + 1) + 4*(a^2 
*d*f*x + a^2*c*f)*sin(2*f*x + 2*e))/(f^2*cos(2*f*x + 2*e)^2 + f^2*sin(2*f* 
x + 2*e)^2 + 2*f^2*cos(2*f*x + 2*e) + f^2)
 

Giac [F]

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

integrate((d*x+c)*(a+a*sec(f*x+e))^2,x, algorithm="giac")
 

Output:

integrate((d*x + c)*(a*sec(f*x + e) + a)^2, x)
 

Mupad [F(-1)]

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

int((a + a/cos(e + f*x))^2*(c + d*x),x)
 

Output:

int((a + a/cos(e + f*x))^2*(c + d*x), x)
 

Reduce [F]

\[ \int (c+d x) (a+a \sec (e+f x))^2 \, dx=\frac {a^{2} \left (4 \cos \left (f x +e \right ) \left (\int \frac {x}{\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{4}-2 \tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2}+1}d x \right ) d f -2 \cos \left (f x +e \right ) \mathrm {log}\left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right ) c +2 \cos \left (f x +e \right ) \mathrm {log}\left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right ) c +\cos \left (f x +e \right ) c f x +\sin \left (f x +e \right ) c \right )}{\cos \left (f x +e \right ) f} \] Input:

int((d*x+c)*(a+a*sec(f*x+e))^2,x)
 

Output:

(a**2*(4*cos(e + f*x)*int(x/(tan((e + f*x)/2)**4 - 2*tan((e + f*x)/2)**2 + 
 1),x)*d*f - 2*cos(e + f*x)*log(tan((e + f*x)/2) - 1)*c + 2*cos(e + f*x)*l 
og(tan((e + f*x)/2) + 1)*c + cos(e + f*x)*c*f*x + sin(e + f*x)*c))/(cos(e 
+ f*x)*f)