\(\int \frac {(c+d x)^2}{a+a \sec (e+f x)} \, dx\) [12]

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

Optimal result

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

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

Mathematica [B] (warning: unable to verify)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(528\) vs. \(2(119)=238\).

Time = 6.45 (sec) , antiderivative size = 528, normalized size of antiderivative = 4.44 \[ \int \frac {(c+d x)^2}{a+a \sec (e+f x)} \, dx=\frac {2 x \left (3 c^2+3 c d x+d^2 x^2\right ) \cos ^2\left (\frac {e}{2}+\frac {f x}{2}\right ) \sec (e+f x)}{3 (a+a \sec (e+f x))}-\frac {8 c d \cos ^2\left (\frac {e}{2}+\frac {f x}{2}\right ) \sec \left (\frac {e}{2}\right ) \sec (e+f x) \left (\cos \left (\frac {e}{2}\right ) \log \left (\cos \left (\frac {e}{2}\right ) \cos \left (\frac {f x}{2}\right )-\sin \left (\frac {e}{2}\right ) \sin \left (\frac {f x}{2}\right )\right )+\frac {1}{2} f x \sin \left (\frac {e}{2}\right )\right )}{f^2 (a+a \sec (e+f x)) \left (\cos ^2\left (\frac {e}{2}\right )+\sin ^2\left (\frac {e}{2}\right )\right )}-\frac {8 d^2 \cos ^2\left (\frac {e}{2}+\frac {f x}{2}\right ) \csc \left (\frac {e}{2}\right ) \left (\frac {1}{4} e^{-i \arctan \left (\cot \left (\frac {e}{2}\right )\right )} f^2 x^2-\frac {\cot \left (\frac {e}{2}\right ) \left (\frac {1}{2} i f x \left (-\pi -2 \arctan \left (\cot \left (\frac {e}{2}\right )\right )\right )-\pi \log \left (1+e^{-i f x}\right )-2 \left (\frac {f x}{2}-\arctan \left (\cot \left (\frac {e}{2}\right )\right )\right ) \log \left (1-e^{2 i \left (\frac {f x}{2}-\arctan \left (\cot \left (\frac {e}{2}\right )\right )\right )}\right )+\pi \log \left (\cos \left (\frac {f x}{2}\right )\right )-2 \arctan \left (\cot \left (\frac {e}{2}\right )\right ) \log \left (\sin \left (\frac {f x}{2}-\arctan \left (\cot \left (\frac {e}{2}\right )\right )\right )\right )+i \operatorname {PolyLog}\left (2,e^{2 i \left (\frac {f x}{2}-\arctan \left (\cot \left (\frac {e}{2}\right )\right )\right )}\right )\right )}{\sqrt {1+\cot ^2\left (\frac {e}{2}\right )}}\right ) \sec \left (\frac {e}{2}\right ) \sec (e+f x)}{f^3 (a+a \sec (e+f x)) \sqrt {\csc ^2\left (\frac {e}{2}\right ) \left (\cos ^2\left (\frac {e}{2}\right )+\sin ^2\left (\frac {e}{2}\right )\right )}}-\frac {2 \cos \left (\frac {e}{2}+\frac {f x}{2}\right ) \sec \left (\frac {e}{2}\right ) \sec (e+f x) \left (c^2 \sin \left (\frac {f x}{2}\right )+2 c d x \sin \left (\frac {f x}{2}\right )+d^2 x^2 \sin \left (\frac {f x}{2}\right )\right )}{f (a+a \sec (e+f x))} \] Input:

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

Output:

(2*x*(3*c^2 + 3*c*d*x + d^2*x^2)*Cos[e/2 + (f*x)/2]^2*Sec[e + f*x])/(3*(a 
+ a*Sec[e + f*x])) - (8*c*d*Cos[e/2 + (f*x)/2]^2*Sec[e/2]*Sec[e + f*x]*(Co 
s[e/2]*Log[Cos[e/2]*Cos[(f*x)/2] - Sin[e/2]*Sin[(f*x)/2]] + (f*x*Sin[e/2]) 
/2))/(f^2*(a + a*Sec[e + f*x])*(Cos[e/2]^2 + Sin[e/2]^2)) - (8*d^2*Cos[e/2 
 + (f*x)/2]^2*Csc[e/2]*((f^2*x^2)/(4*E^(I*ArcTan[Cot[e/2]])) - (Cot[e/2]*( 
(I/2)*f*x*(-Pi - 2*ArcTan[Cot[e/2]]) - Pi*Log[1 + E^((-I)*f*x)] - 2*((f*x) 
/2 - ArcTan[Cot[e/2]])*Log[1 - E^((2*I)*((f*x)/2 - ArcTan[Cot[e/2]]))] + P 
i*Log[Cos[(f*x)/2]] - 2*ArcTan[Cot[e/2]]*Log[Sin[(f*x)/2 - ArcTan[Cot[e/2] 
]]] + I*PolyLog[2, E^((2*I)*((f*x)/2 - ArcTan[Cot[e/2]]))]))/Sqrt[1 + Cot[ 
e/2]^2])*Sec[e/2]*Sec[e + f*x])/(f^3*(a + a*Sec[e + f*x])*Sqrt[Csc[e/2]^2* 
(Cos[e/2]^2 + Sin[e/2]^2)]) - (2*Cos[e/2 + (f*x)/2]*Sec[e/2]*Sec[e + f*x]* 
(c^2*Sin[(f*x)/2] + 2*c*d*x*Sin[(f*x)/2] + d^2*x^2*Sin[(f*x)/2]))/(f*(a + 
a*Sec[e + f*x]))
 

Rubi [A] (verified)

Time = 0.47 (sec) , antiderivative size = 119, 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.150, Rules used = {3042, 4679, 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 \frac {(c+d x)^2}{a \sec (e+f x)+a} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4679

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

\(\Big \downarrow \) 2009

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

Input:

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

Output:

(I*(c + d*x)^2)/(a*f) + (c + d*x)^3/(3*a*d) - (4*d*(c + d*x)*Log[1 + E^(I* 
(e + f*x))])/(a*f^2) + ((4*I)*d^2*PolyLog[2, -E^(I*(e + f*x))])/(a*f^3) - 
((c + d*x)^2*Tan[e/2 + (f*x)/2])/(a*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 4679
Int[(csc[(e_.) + (f_.)*(x_)]*(b_.) + (a_))^(n_.)*((c_.) + (d_.)*(x_))^(m_.) 
, x_Symbol] :> Int[ExpandIntegrand[(c + d*x)^m, 1/(Sin[e + f*x]^n/(b + a*Si 
n[e + f*x])^n), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && ILtQ[n, 0] && IGt 
Q[m, 0]
 
Maple [B] (verified)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 235 vs. \(2 (107 ) = 214\).

Time = 0.14 (sec) , antiderivative size = 236, normalized size of antiderivative = 1.98

method result size
risch \(\frac {d^{2} x^{3}}{3 a}+\frac {d c \,x^{2}}{a}+\frac {c^{2} x}{a}+\frac {c^{3}}{3 a d}-\frac {2 i \left (d^{2} x^{2}+2 c d x +c^{2}\right )}{f a \left (1+{\mathrm e}^{i \left (f x +e \right )}\right )}-\frac {4 d c \ln \left (1+{\mathrm e}^{i \left (f x +e \right )}\right )}{a \,f^{2}}+\frac {4 d c \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{a \,f^{2}}+\frac {2 i d^{2} x^{2}}{a f}+\frac {4 i d^{2} e x}{a \,f^{2}}+\frac {2 i d^{2} e^{2}}{a \,f^{3}}-\frac {4 d^{2} \ln \left (1+{\mathrm e}^{i \left (f x +e \right )}\right ) x}{a \,f^{2}}+\frac {4 i d^{2} \operatorname {polylog}\left (2, -{\mathrm e}^{i \left (f x +e \right )}\right )}{a \,f^{3}}-\frac {4 d^{2} e \ln \left ({\mathrm e}^{i \left (f x +e \right )}\right )}{a \,f^{3}}\) \(236\)

Input:

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

Output:

1/3/a*d^2*x^3+1/a*d*c*x^2+1/a*c^2*x+1/3/a/d*c^3-2*I*(d^2*x^2+2*c*d*x+c^2)/ 
f/a/(1+exp(I*(f*x+e)))-4/a/f^2*d*c*ln(1+exp(I*(f*x+e)))+4/a/f^2*d*c*ln(exp 
(I*(f*x+e)))+2*I/a/f*d^2*x^2+4*I/a/f^2*d^2*e*x+2*I/a/f^3*d^2*e^2-4/a/f^2*d 
^2*ln(1+exp(I*(f*x+e)))*x+4*I*d^2*polylog(2,-exp(I*(f*x+e)))/a/f^3-4/a/f^3 
*d^2*e*ln(exp(I*(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. 292 vs. \(2 (104) = 208\).

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

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

Output:

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

Sympy [F]

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

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

Output:

(Integral(c**2/(sec(e + f*x) + 1), x) + Integral(d**2*x**2/(sec(e + f*x) + 
 1), x) + Integral(2*c*d*x/(sec(e + f*x) + 1), x))/a
 

Maxima [B] (verification not implemented)

Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 377 vs. \(2 (104) = 208\).

Time = 0.22 (sec) , antiderivative size = 377, normalized size of antiderivative = 3.17 \[ \int \frac {(c+d x)^2}{a+a \sec (e+f x)} \, dx=-\frac {i \, d^{2} f^{3} x^{3} + 3 i \, c d f^{3} x^{2} + 3 i \, c^{2} f^{3} x + 6 \, c^{2} f^{2} + 12 \, {\left (d^{2} f x + c d f + {\left (d^{2} f x + c d f\right )} \cos \left (f x + e\right ) - {\left (-i \, d^{2} f x - i \, c d f\right )} \sin \left (f x + e\right )\right )} \arctan \left (\sin \left (f x + e\right ), \cos \left (f x + e\right ) + 1\right ) + {\left (i \, d^{2} f^{3} x^{3} - 3 \, {\left (-i \, c d f^{3} + 2 \, d^{2} f^{2}\right )} x^{2} - 3 \, {\left (-i \, c^{2} f^{3} + 4 \, c d f^{2}\right )} x\right )} \cos \left (f x + e\right ) - 12 \, {\left (d^{2} \cos \left (f x + e\right ) + i \, d^{2} \sin \left (f x + e\right ) + d^{2}\right )} {\rm Li}_2\left (-e^{\left (i \, f x + i \, e\right )}\right ) - 6 \, {\left (i \, d^{2} f x + i \, c d f + {\left (i \, d^{2} f x + i \, c d f\right )} \cos \left (f x + e\right ) - {\left (d^{2} f x + c d f\right )} \sin \left (f x + e\right )\right )} \log \left (\cos \left (f x + e\right )^{2} + \sin \left (f x + e\right )^{2} + 2 \, \cos \left (f x + e\right ) + 1\right ) - {\left (d^{2} f^{3} x^{3} + 3 \, {\left (c d f^{3} + 2 i \, d^{2} f^{2}\right )} x^{2} + 3 \, {\left (c^{2} f^{3} + 4 i \, c d f^{2}\right )} x\right )} \sin \left (f x + e\right )}{-3 i \, a f^{3} \cos \left (f x + e\right ) + 3 \, a f^{3} \sin \left (f x + e\right ) - 3 i \, a f^{3}} \] Input:

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

Output:

-(I*d^2*f^3*x^3 + 3*I*c*d*f^3*x^2 + 3*I*c^2*f^3*x + 6*c^2*f^2 + 12*(d^2*f* 
x + c*d*f + (d^2*f*x + c*d*f)*cos(f*x + e) - (-I*d^2*f*x - I*c*d*f)*sin(f* 
x + e))*arctan2(sin(f*x + e), cos(f*x + e) + 1) + (I*d^2*f^3*x^3 - 3*(-I*c 
*d*f^3 + 2*d^2*f^2)*x^2 - 3*(-I*c^2*f^3 + 4*c*d*f^2)*x)*cos(f*x + e) - 12* 
(d^2*cos(f*x + e) + I*d^2*sin(f*x + e) + d^2)*dilog(-e^(I*f*x + I*e)) - 6* 
(I*d^2*f*x + I*c*d*f + (I*d^2*f*x + I*c*d*f)*cos(f*x + e) - (d^2*f*x + c*d 
*f)*sin(f*x + e))*log(cos(f*x + e)^2 + sin(f*x + e)^2 + 2*cos(f*x + e) + 1 
) - (d^2*f^3*x^3 + 3*(c*d*f^3 + 2*I*d^2*f^2)*x^2 + 3*(c^2*f^3 + 4*I*c*d*f^ 
2)*x)*sin(f*x + e))/(-3*I*a*f^3*cos(f*x + e) + 3*a*f^3*sin(f*x + e) - 3*I* 
a*f^3)
 

Giac [F]

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

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

Output:

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

Mupad [F(-1)]

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

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

Output:

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

Reduce [F]

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

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

Output:

(6*int(tan((e + f*x)/2)*x,x)*d**2*f + 6*log(tan((e + f*x)/2)**2 + 1)*c*d - 
 3*tan((e + f*x)/2)*c**2*f - 6*tan((e + f*x)/2)*c*d*f*x - 3*tan((e + f*x)/ 
2)*d**2*f*x**2 + 3*c**2*f**2*x + 3*c*d*f**2*x**2 + d**2*f**2*x**3)/(3*a*f* 
*2)