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

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

Optimal result

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

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

Mathematica [A] (verified)

Time = 0.75 (sec) , antiderivative size = 338, normalized size of antiderivative = 0.86 \[ \int \frac {(c+d x)^2}{a+b \sec (e+f x)} \, dx=\frac {(b+a \cos (e+f x)) \left (x \left (3 c^2+3 c d x+d^2 x^2\right )+\frac {3 i b \left ((c+d x)^2 \log \left (1-\frac {a e^{i (e+f x)}}{-b+\sqrt {-a^2+b^2}}\right )-(c+d x)^2 \log \left (1+\frac {a e^{i (e+f x)}}{b+\sqrt {-a^2+b^2}}\right )+\frac {2 d \left (-i f (c+d x) \operatorname {PolyLog}\left (2,\frac {a e^{i (e+f x)}}{-b+\sqrt {-a^2+b^2}}\right )+d \operatorname {PolyLog}\left (3,\frac {a e^{i (e+f x)}}{-b+\sqrt {-a^2+b^2}}\right )\right )}{f^2}+\frac {2 i d \left (f (c+d x) \operatorname {PolyLog}\left (2,-\frac {a e^{i (e+f x)}}{b+\sqrt {-a^2+b^2}}\right )+i d \operatorname {PolyLog}\left (3,-\frac {a e^{i (e+f x)}}{b+\sqrt {-a^2+b^2}}\right )\right )}{f^2}\right )}{\sqrt {-a^2+b^2} f}\right ) \sec (e+f x)}{3 a (a+b \sec (e+f x))} \] Input:

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

Output:

((b + a*Cos[e + f*x])*(x*(3*c^2 + 3*c*d*x + d^2*x^2) + ((3*I)*b*((c + d*x) 
^2*Log[1 - (a*E^(I*(e + f*x)))/(-b + Sqrt[-a^2 + b^2])] - (c + d*x)^2*Log[ 
1 + (a*E^(I*(e + f*x)))/(b + Sqrt[-a^2 + b^2])] + (2*d*((-I)*f*(c + d*x)*P 
olyLog[2, (a*E^(I*(e + f*x)))/(-b + Sqrt[-a^2 + b^2])] + d*PolyLog[3, (a*E 
^(I*(e + f*x)))/(-b + Sqrt[-a^2 + b^2])]))/f^2 + ((2*I)*d*(f*(c + d*x)*Pol 
yLog[2, -((a*E^(I*(e + f*x)))/(b + Sqrt[-a^2 + b^2]))] + I*d*PolyLog[3, -( 
(a*E^(I*(e + f*x)))/(b + Sqrt[-a^2 + b^2]))]))/f^2))/(Sqrt[-a^2 + b^2]*f)) 
*Sec[e + f*x])/(3*a*(a + b*Sec[e + f*x]))
 

Rubi [A] (verified)

Time = 1.09 (sec) , antiderivative size = 394, 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+b \sec (e+f x)} \, dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4679

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

\(\Big \downarrow \) 2009

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

Input:

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

Output:

(c + d*x)^3/(3*a*d) + (I*b*(c + d*x)^2*Log[1 + (a*E^(I*(e + f*x)))/(b - Sq 
rt[-a^2 + b^2])])/(a*Sqrt[-a^2 + b^2]*f) - (I*b*(c + d*x)^2*Log[1 + (a*E^( 
I*(e + f*x)))/(b + Sqrt[-a^2 + b^2])])/(a*Sqrt[-a^2 + b^2]*f) + (2*b*d*(c 
+ d*x)*PolyLog[2, -((a*E^(I*(e + f*x)))/(b - Sqrt[-a^2 + b^2]))])/(a*Sqrt[ 
-a^2 + b^2]*f^2) - (2*b*d*(c + d*x)*PolyLog[2, -((a*E^(I*(e + f*x)))/(b + 
Sqrt[-a^2 + b^2]))])/(a*Sqrt[-a^2 + b^2]*f^2) + ((2*I)*b*d^2*PolyLog[3, -( 
(a*E^(I*(e + f*x)))/(b - Sqrt[-a^2 + b^2]))])/(a*Sqrt[-a^2 + b^2]*f^3) - ( 
(2*I)*b*d^2*PolyLog[3, -((a*E^(I*(e + f*x)))/(b + Sqrt[-a^2 + b^2]))])/(a* 
Sqrt[-a^2 + b^2]*f^3)
 

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 [F]

\[\int \frac {\left (d x +c \right )^{2}}{a +b \sec \left (f x +e \right )}d x\]

Input:

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

Output:

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

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. 1625 vs. \(2 (346) = 692\).

Time = 0.24 (sec) , antiderivative size = 1625, normalized size of antiderivative = 4.12 \[ \int \frac {(c+d x)^2}{a+b \sec (e+f x)} \, dx=\text {Too large to display} \] Input:

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

Output:

1/6*(2*(a^2 - b^2)*d^2*f^3*x^3 + 6*(a^2 - b^2)*c*d*f^3*x^2 + 6*(a^2 - b^2) 
*c^2*f^3*x - 6*I*a*b*d^2*sqrt(-(a^2 - b^2)/a^2)*polylog(3, -(b*cos(f*x + e 
) + I*b*sin(f*x + e) + (a*cos(f*x + e) + I*a*sin(f*x + e))*sqrt(-(a^2 - b^ 
2)/a^2))/a) + 6*I*a*b*d^2*sqrt(-(a^2 - b^2)/a^2)*polylog(3, -(b*cos(f*x + 
e) + I*b*sin(f*x + e) - (a*cos(f*x + e) + I*a*sin(f*x + e))*sqrt(-(a^2 - b 
^2)/a^2))/a) + 6*I*a*b*d^2*sqrt(-(a^2 - b^2)/a^2)*polylog(3, -(b*cos(f*x + 
 e) - I*b*sin(f*x + e) + (a*cos(f*x + e) - I*a*sin(f*x + e))*sqrt(-(a^2 - 
b^2)/a^2))/a) - 6*I*a*b*d^2*sqrt(-(a^2 - b^2)/a^2)*polylog(3, -(b*cos(f*x 
+ e) - I*b*sin(f*x + e) - (a*cos(f*x + e) - I*a*sin(f*x + e))*sqrt(-(a^2 - 
 b^2)/a^2))/a) - 6*(a*b*d^2*f*x + a*b*c*d*f)*sqrt(-(a^2 - b^2)/a^2)*dilog( 
-(b*cos(f*x + e) + I*b*sin(f*x + e) + (a*cos(f*x + e) + I*a*sin(f*x + e))* 
sqrt(-(a^2 - b^2)/a^2) + a)/a + 1) + 6*(a*b*d^2*f*x + a*b*c*d*f)*sqrt(-(a^ 
2 - b^2)/a^2)*dilog(-(b*cos(f*x + e) + I*b*sin(f*x + e) - (a*cos(f*x + e) 
+ I*a*sin(f*x + e))*sqrt(-(a^2 - b^2)/a^2) + a)/a + 1) - 6*(a*b*d^2*f*x + 
a*b*c*d*f)*sqrt(-(a^2 - b^2)/a^2)*dilog(-(b*cos(f*x + e) - I*b*sin(f*x + e 
) + (a*cos(f*x + e) - I*a*sin(f*x + e))*sqrt(-(a^2 - b^2)/a^2) + a)/a + 1) 
 + 6*(a*b*d^2*f*x + a*b*c*d*f)*sqrt(-(a^2 - b^2)/a^2)*dilog(-(b*cos(f*x + 
e) - I*b*sin(f*x + e) - (a*cos(f*x + e) - I*a*sin(f*x + e))*sqrt(-(a^2 - b 
^2)/a^2) + a)/a + 1) + 3*(I*a*b*d^2*e^2 - 2*I*a*b*c*d*e*f + I*a*b*c^2*f^2) 
*sqrt(-(a^2 - b^2)/a^2)*log(2*a*cos(f*x + e) + 2*I*a*sin(f*x + e) + 2*a...
 

Sympy [F]

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

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

Output:

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

Maxima [F(-2)]

Exception generated. \[ \int \frac {(c+d x)^2}{a+b \sec (e+f x)} \, dx=\text {Exception raised: ValueError} \] Input:

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

Output:

Exception raised: ValueError >> Computation failed since Maxima requested 
additional constraints; using the 'assume' command before evaluation *may* 
 help (example of legal syntax is 'assume(4*a^2-4*b^2>0)', see `assume?` f 
or more de
 

Giac [F]

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

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

Output:

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

Mupad [F(-1)]

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

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

Output:

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

Reduce [F]

\[ \int \frac {(c+d x)^2}{a+b \sec (e+f x)} \, dx=\frac {-6 \sqrt {-a^{2}+b^{2}}\, \mathit {atan} \left (\frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right ) a -\tan \left (\frac {f x}{2}+\frac {e}{2}\right ) b}{\sqrt {-a^{2}+b^{2}}}\right ) b \,c^{2}+6 \left (\int \frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} x^{2}}{\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} a^{2}-\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} b^{2}-a^{2}-2 a b -b^{2}}d x \right ) a^{3} b \,d^{2} f -6 \left (\int \frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} x^{2}}{\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} a^{2}-\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} b^{2}-a^{2}-2 a b -b^{2}}d x \right ) a \,b^{3} d^{2} f +12 \left (\int \frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} x}{\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} a^{2}-\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} b^{2}-a^{2}-2 a b -b^{2}}d x \right ) a^{3} b c d f -12 \left (\int \frac {\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} x}{\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} a^{2}-\tan \left (\frac {f x}{2}+\frac {e}{2}\right )^{2} b^{2}-a^{2}-2 a b -b^{2}}d x \right ) a \,b^{3} c d f +3 a^{2} c^{2} f x +3 a^{2} c d f \,x^{2}+a^{2} d^{2} f \,x^{3}-3 a b c d f \,x^{2}-a b \,d^{2} f \,x^{3}-3 b^{2} c^{2} f x}{3 a f \left (a^{2}-b^{2}\right )} \] Input:

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

Output:

( - 6*sqrt( - a**2 + b**2)*atan((tan((e + f*x)/2)*a - tan((e + f*x)/2)*b)/ 
sqrt( - a**2 + b**2))*b*c**2 + 6*int((tan((e + f*x)/2)**2*x**2)/(tan((e + 
f*x)/2)**2*a**2 - tan((e + f*x)/2)**2*b**2 - a**2 - 2*a*b - b**2),x)*a**3* 
b*d**2*f - 6*int((tan((e + f*x)/2)**2*x**2)/(tan((e + f*x)/2)**2*a**2 - ta 
n((e + f*x)/2)**2*b**2 - a**2 - 2*a*b - b**2),x)*a*b**3*d**2*f + 12*int((t 
an((e + f*x)/2)**2*x)/(tan((e + f*x)/2)**2*a**2 - tan((e + f*x)/2)**2*b**2 
 - a**2 - 2*a*b - b**2),x)*a**3*b*c*d*f - 12*int((tan((e + f*x)/2)**2*x)/( 
tan((e + f*x)/2)**2*a**2 - tan((e + f*x)/2)**2*b**2 - a**2 - 2*a*b - b**2) 
,x)*a*b**3*c*d*f + 3*a**2*c**2*f*x + 3*a**2*c*d*f*x**2 + a**2*d**2*f*x**3 
- 3*a*b*c*d*f*x**2 - a*b*d**2*f*x**3 - 3*b**2*c**2*f*x)/(3*a*f*(a**2 - b** 
2))