\(\int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) (A+B \tan (e+f x)+C \tan ^2(e+f x)) \, dx\) [51]

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

Optimal result

Integrand size = 43, antiderivative size = 248 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\left (a^2 (A c-c C-B d)-b^2 (A c-c C-B d)-2 a b (B c+(A-C) d)\right ) x-\frac {\left (2 a b (A c-c C-B d)+a^2 (B c+(A-C) d)-b^2 (B c+(A-C) d)\right ) \log (\cos (e+f x))}{f}+\frac {b (A b c+a B c-b c C+a A d-b B d-a C d) \tan (e+f x)}{f}+\frac {(B c+(A-C) d) (a+b \tan (e+f x))^2}{2 f}-\frac {(a C d-4 b (c C+B d)) (a+b \tan (e+f x))^3}{12 b^2 f}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f} \] Output:

(a^2*(A*c-B*d-C*c)-b^2*(A*c-B*d-C*c)-2*a*b*(B*c+(A-C)*d))*x-(2*a*b*(A*c-B* 
d-C*c)+a^2*(B*c+(A-C)*d)-b^2*(B*c+(A-C)*d))*ln(cos(f*x+e))/f+b*(A*a*d+A*b* 
c+B*a*c-B*b*d-C*a*d-C*b*c)*tan(f*x+e)/f+1/2*(B*c+(A-C)*d)*(a+b*tan(f*x+e)) 
^2/f-1/12*(C*a*d-4*b*(B*d+C*c))*(a+b*tan(f*x+e))^3/b^2/f+1/4*C*d*tan(f*x+e 
)*(a+b*tan(f*x+e))^3/b/f
                                                                                    
                                                                                    
 

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 2.23 (sec) , antiderivative size = 243, normalized size of antiderivative = 0.98 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {\frac {(-a C d+4 b (c C+B d)) (a+b \tan (e+f x))^3}{b}+3 C d \tan (e+f x) (a+b \tan (e+f x))^3-6 (A b c-a B c-b c C-a A d-b B d+a C d) \left (i \left ((a+i b)^2 \log (i-\tan (e+f x))-(a-i b)^2 \log (i+\tan (e+f x))\right )-2 b^2 \tan (e+f x)\right )+6 (B c+(A-C) d) \left ((i a-b)^3 \log (i-\tan (e+f x))-(i a+b)^3 \log (i+\tan (e+f x))+6 a b^2 \tan (e+f x)+b^3 \tan ^2(e+f x)\right )}{12 b f} \] Input:

Integrate[(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x])*(A + B*Tan[e + f*x] 
+ C*Tan[e + f*x]^2),x]
 

Output:

(((-(a*C*d) + 4*b*(c*C + B*d))*(a + b*Tan[e + f*x])^3)/b + 3*C*d*Tan[e + f 
*x]*(a + b*Tan[e + f*x])^3 - 6*(A*b*c - a*B*c - b*c*C - a*A*d - b*B*d + a* 
C*d)*(I*((a + I*b)^2*Log[I - Tan[e + f*x]] - (a - I*b)^2*Log[I + Tan[e + f 
*x]]) - 2*b^2*Tan[e + f*x]) + 6*(B*c + (A - C)*d)*((I*a - b)^3*Log[I - Tan 
[e + f*x]] - (I*a + b)^3*Log[I + Tan[e + f*x]] + 6*a*b^2*Tan[e + f*x] + b^ 
3*Tan[e + f*x]^2))/(12*b*f)
 

Rubi [A] (verified)

Time = 1.87 (sec) , antiderivative size = 261, normalized size of antiderivative = 1.05, number of steps used = 11, number of rules used = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.256, Rules used = {3042, 4120, 25, 3042, 4113, 3042, 4011, 3042, 4008, 3042, 3956}

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 (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan (e+f x)^2\right )dx\)

\(\Big \downarrow \) 4120

\(\displaystyle \frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}-\frac {\int -(a+b \tan (e+f x))^2 \left (-\left ((a C d-4 b (c C+B d)) \tan ^2(e+f x)\right )+4 b (B c+(A-C) d) \tan (e+f x)+4 A b c-a C d\right )dx}{4 b}\)

\(\Big \downarrow \) 25

\(\displaystyle \frac {\int (a+b \tan (e+f x))^2 \left (-\left ((a C d-4 b (c C+B d)) \tan ^2(e+f x)\right )+4 b (B c+(A-C) d) \tan (e+f x)+4 A b c-a C d\right )dx}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int (a+b \tan (e+f x))^2 \left (-\left ((a C d-4 b (c C+B d)) \tan (e+f x)^2\right )+4 b (B c+(A-C) d) \tan (e+f x)+4 A b c-a C d\right )dx}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 4113

\(\displaystyle \frac {\int (a+b \tan (e+f x))^2 (4 b (A c-C c-B d)+4 b (B c+(A-C) d) \tan (e+f x))dx-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{3 b f}}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int (a+b \tan (e+f x))^2 (4 b (A c-C c-B d)+4 b (B c+(A-C) d) \tan (e+f x))dx-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{3 b f}}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 4011

\(\displaystyle \frac {\int (a+b \tan (e+f x)) (4 b (A b c+a B c-b C c+a A d-b B d-a C d) \tan (e+f x)-4 b (b B c+b (A-C) d-a (A c-C c-B d)))dx+\frac {2 b (d (A-C)+B c) (a+b \tan (e+f x))^2}{f}-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{3 b f}}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int (a+b \tan (e+f x)) (4 b (A b c+a B c-b C c+a A d-b B d-a C d) \tan (e+f x)-4 b (b B c+b (A-C) d-a (A c-C c-B d)))dx+\frac {2 b (d (A-C)+B c) (a+b \tan (e+f x))^2}{f}-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{3 b f}}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 4008

\(\displaystyle \frac {4 b \left (a^2 (d (A-C)+B c)+2 a b (A c-B d-c C)-b^2 (d (A-C)+B c)\right ) \int \tan (e+f x)dx+4 b x \left (a^2 (A c-B d-c C)-2 a b (d (A-C)+B c)-b^2 (A c-B d-c C)\right )+\frac {4 b^2 \tan (e+f x) (a A d+a B c-a C d+A b c-b B d-b c C)}{f}+\frac {2 b (d (A-C)+B c) (a+b \tan (e+f x))^2}{f}-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{3 b f}}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {4 b \left (a^2 (d (A-C)+B c)+2 a b (A c-B d-c C)-b^2 (d (A-C)+B c)\right ) \int \tan (e+f x)dx+4 b x \left (a^2 (A c-B d-c C)-2 a b (d (A-C)+B c)-b^2 (A c-B d-c C)\right )+\frac {4 b^2 \tan (e+f x) (a A d+a B c-a C d+A b c-b B d-b c C)}{f}+\frac {2 b (d (A-C)+B c) (a+b \tan (e+f x))^2}{f}-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{3 b f}}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

\(\Big \downarrow \) 3956

\(\displaystyle \frac {-\frac {4 b \log (\cos (e+f x)) \left (a^2 (d (A-C)+B c)+2 a b (A c-B d-c C)-b^2 (d (A-C)+B c)\right )}{f}+4 b x \left (a^2 (A c-B d-c C)-2 a b (d (A-C)+B c)-b^2 (A c-B d-c C)\right )+\frac {4 b^2 \tan (e+f x) (a A d+a B c-a C d+A b c-b B d-b c C)}{f}+\frac {2 b (d (A-C)+B c) (a+b \tan (e+f x))^2}{f}-\frac {(a C d-4 b (B d+c C)) (a+b \tan (e+f x))^3}{3 b f}}{4 b}+\frac {C d \tan (e+f x) (a+b \tan (e+f x))^3}{4 b f}\)

Input:

Int[(a + b*Tan[e + f*x])^2*(c + d*Tan[e + f*x])*(A + B*Tan[e + f*x] + C*Ta 
n[e + f*x]^2),x]
 

Output:

(C*d*Tan[e + f*x]*(a + b*Tan[e + f*x])^3)/(4*b*f) + (4*b*(a^2*(A*c - c*C - 
 B*d) - b^2*(A*c - c*C - B*d) - 2*a*b*(B*c + (A - C)*d))*x - (4*b*(2*a*b*( 
A*c - c*C - B*d) + a^2*(B*c + (A - C)*d) - b^2*(B*c + (A - C)*d))*Log[Cos[ 
e + f*x]])/f + (4*b^2*(A*b*c + a*B*c - b*c*C + a*A*d - b*B*d - a*C*d)*Tan[ 
e + f*x])/f + (2*b*(B*c + (A - C)*d)*(a + b*Tan[e + f*x])^2)/f - ((a*C*d - 
 4*b*(c*C + B*d))*(a + b*Tan[e + f*x])^3)/(3*b*f))/(4*b)
 

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 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4008
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)]), x_Symbol] :> Simp[(a*c - b*d)*x, x] + (Simp[b*d*(Tan[e + f*x]/f), 
x] + Simp[(b*c + a*d)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, c, d, e, 
f}, x] && NeQ[b*c - a*d, 0] && NeQ[b*c + a*d, 0]
 

rule 4011
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)]), x_Symbol] :> Simp[d*((a + b*Tan[e + f*x])^m/(f*m)), x] + Int 
[(a + b*Tan[e + f*x])^(m - 1)*Simp[a*c - b*d + (b*c + a*d)*Tan[e + f*x], x] 
, x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 
 0] && GtQ[m, 0]
 

rule 4113
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) 
+ (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*((a + 
 b*Tan[e + f*x])^(m + 1)/(b*f*(m + 1))), x] + Int[(a + b*Tan[e + f*x])^m*Si 
mp[A - C + B*Tan[e + f*x], x], x] /; FreeQ[{a, b, e, f, A, B, C, m}, x] && 
NeQ[A*b^2 - a*b*B + a^2*C, 0] &&  !LeQ[m, -1]
 

rule 4120
Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.) 
*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f 
_.)*(x_)]^2), x_Symbol] :> Simp[b*C*Tan[e + f*x]*((c + d*Tan[e + f*x])^(n + 
 1)/(d*f*(n + 2))), x] - Simp[1/(d*(n + 2))   Int[(c + d*Tan[e + f*x])^n*Si 
mp[b*c*C - a*A*d*(n + 2) - (A*b + a*B - b*C)*d*(n + 2)*Tan[e + f*x] - (a*C* 
d*(n + 2) - b*(c*C - B*d*(n + 2)))*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, 
b, c, d, e, f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[c^2 + d^2, 0] && 
  !LtQ[n, -1]
 
Maple [A] (warning: unable to verify)

Time = 0.21 (sec) , antiderivative size = 246, normalized size of antiderivative = 0.99

method result size
parts \(\frac {\left (A \,a^{2} d +2 A a b c +B \,a^{2} c \right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}+\frac {\left (B \,b^{2} d +2 C a b d +C \,b^{2} c \right ) \left (\frac {\tan \left (f x +e \right )^{3}}{3}-\tan \left (f x +e \right )+\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+\frac {\left (A \,b^{2} d +2 B a b d +B \,b^{2} c +C \,a^{2} d +2 C a b c \right ) \left (\frac {\tan \left (f x +e \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}+\frac {\left (2 A a b d +A \,b^{2} c +B \,a^{2} d +2 B a b c +C \,a^{2} c \right ) \left (\tan \left (f x +e \right )-\arctan \left (\tan \left (f x +e \right )\right )\right )}{f}+A \,a^{2} c x +\frac {d C \,b^{2} \left (\frac {\tan \left (f x +e \right )^{4}}{4}-\frac {\tan \left (f x +e \right )^{2}}{2}+\frac {\ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}\right )}{f}\) \(246\)
norman \(\left (A \,a^{2} c -2 A a b d -A \,b^{2} c -B \,a^{2} d -2 B a b c +B \,b^{2} d -C \,a^{2} c +2 C a b d +C \,b^{2} c \right ) x +\frac {\left (2 A a b d +A \,b^{2} c +B \,a^{2} d +2 B a b c -B \,b^{2} d +C \,a^{2} c -2 C a b d -C \,b^{2} c \right ) \tan \left (f x +e \right )}{f}+\frac {\left (A \,b^{2} d +2 B a b d +B \,b^{2} c +C \,a^{2} d +2 C a b c -d C \,b^{2}\right ) \tan \left (f x +e \right )^{2}}{2 f}+\frac {b \left (B b d +2 C a d +C b c \right ) \tan \left (f x +e \right )^{3}}{3 f}+\frac {d C \,b^{2} \tan \left (f x +e \right )^{4}}{4 f}+\frac {\left (A \,a^{2} d +2 A a b c -A \,b^{2} d +B \,a^{2} c -2 B a b d -B \,b^{2} c -C \,a^{2} d -2 C a b c +d C \,b^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f}\) \(294\)
derivativedivides \(\frac {\frac {d C \,b^{2} \tan \left (f x +e \right )^{4}}{4}+\frac {B \,b^{2} d \tan \left (f x +e \right )^{3}}{3}+\frac {2 C a b d \tan \left (f x +e \right )^{3}}{3}+\frac {C \,b^{2} c \tan \left (f x +e \right )^{3}}{3}+\frac {A \,b^{2} d \tan \left (f x +e \right )^{2}}{2}+B a b d \tan \left (f x +e \right )^{2}+\frac {B \,b^{2} c \tan \left (f x +e \right )^{2}}{2}+\frac {C \,a^{2} d \tan \left (f x +e \right )^{2}}{2}+C a b c \tan \left (f x +e \right )^{2}-\frac {C \,b^{2} d \tan \left (f x +e \right )^{2}}{2}+2 \tan \left (f x +e \right ) A a b d +\tan \left (f x +e \right ) A \,b^{2} c +\tan \left (f x +e \right ) B \,a^{2} d +2 \tan \left (f x +e \right ) B a b c -\tan \left (f x +e \right ) B \,b^{2} d +\tan \left (f x +e \right ) C \,a^{2} c -2 \tan \left (f x +e \right ) C a b d -\tan \left (f x +e \right ) C \,b^{2} c +\frac {\left (A \,a^{2} d +2 A a b c -A \,b^{2} d +B \,a^{2} c -2 B a b d -B \,b^{2} c -C \,a^{2} d -2 C a b c +d C \,b^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,a^{2} c -2 A a b d -A \,b^{2} c -B \,a^{2} d -2 B a b c +B \,b^{2} d -C \,a^{2} c +2 C a b d +C \,b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(386\)
default \(\frac {\frac {d C \,b^{2} \tan \left (f x +e \right )^{4}}{4}+\frac {B \,b^{2} d \tan \left (f x +e \right )^{3}}{3}+\frac {2 C a b d \tan \left (f x +e \right )^{3}}{3}+\frac {C \,b^{2} c \tan \left (f x +e \right )^{3}}{3}+\frac {A \,b^{2} d \tan \left (f x +e \right )^{2}}{2}+B a b d \tan \left (f x +e \right )^{2}+\frac {B \,b^{2} c \tan \left (f x +e \right )^{2}}{2}+\frac {C \,a^{2} d \tan \left (f x +e \right )^{2}}{2}+C a b c \tan \left (f x +e \right )^{2}-\frac {C \,b^{2} d \tan \left (f x +e \right )^{2}}{2}+2 \tan \left (f x +e \right ) A a b d +\tan \left (f x +e \right ) A \,b^{2} c +\tan \left (f x +e \right ) B \,a^{2} d +2 \tan \left (f x +e \right ) B a b c -\tan \left (f x +e \right ) B \,b^{2} d +\tan \left (f x +e \right ) C \,a^{2} c -2 \tan \left (f x +e \right ) C a b d -\tan \left (f x +e \right ) C \,b^{2} c +\frac {\left (A \,a^{2} d +2 A a b c -A \,b^{2} d +B \,a^{2} c -2 B a b d -B \,b^{2} c -C \,a^{2} d -2 C a b c +d C \,b^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A \,a^{2} c -2 A a b d -A \,b^{2} c -B \,a^{2} d -2 B a b c +B \,b^{2} d -C \,a^{2} c +2 C a b d +C \,b^{2} c \right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) \(386\)
parallelrisch \(\frac {3 d C \,b^{2} \tan \left (f x +e \right )^{4}+4 B \,b^{2} d \tan \left (f x +e \right )^{3}+4 C \,b^{2} c \tan \left (f x +e \right )^{3}+6 A \,b^{2} d \tan \left (f x +e \right )^{2}+6 B \,b^{2} c \tan \left (f x +e \right )^{2}+6 C \,a^{2} d \tan \left (f x +e \right )^{2}-6 C \,b^{2} d \tan \left (f x +e \right )^{2}+12 \tan \left (f x +e \right ) A \,b^{2} c +12 \tan \left (f x +e \right ) B \,a^{2} d -12 \tan \left (f x +e \right ) B \,b^{2} d +12 \tan \left (f x +e \right ) C \,a^{2} c -12 \tan \left (f x +e \right ) C \,b^{2} c +8 C a b d \tan \left (f x +e \right )^{3}+12 B a b d \tan \left (f x +e \right )^{2}+12 C a b c \tan \left (f x +e \right )^{2}+24 \tan \left (f x +e \right ) A a b d +24 \tan \left (f x +e \right ) B a b c -24 \tan \left (f x +e \right ) C a b d +12 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b c -12 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b d -12 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a b c +6 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} d -6 A \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} d +6 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} c -6 B \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} c -6 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) a^{2} d +6 C \ln \left (1+\tan \left (f x +e \right )^{2}\right ) b^{2} d +12 A \,a^{2} c f x -12 A \,b^{2} c f x -12 B \,a^{2} d f x +12 B \,b^{2} d f x -12 C \,a^{2} c f x +12 C \,b^{2} c f x -24 A a b d f x -24 B a b c f x +24 C a b d f x}{12 f}\) \(492\)
risch \(\text {Expression too large to display}\) \(1191\)

Input:

int((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x, 
method=_RETURNVERBOSE)
 

Output:

1/2*(A*a^2*d+2*A*a*b*c+B*a^2*c)/f*ln(1+tan(f*x+e)^2)+(B*b^2*d+2*C*a*b*d+C* 
b^2*c)/f*(1/3*tan(f*x+e)^3-tan(f*x+e)+arctan(tan(f*x+e)))+(A*b^2*d+2*B*a*b 
*d+B*b^2*c+C*a^2*d+2*C*a*b*c)/f*(1/2*tan(f*x+e)^2-1/2*ln(1+tan(f*x+e)^2))+ 
(2*A*a*b*d+A*b^2*c+B*a^2*d+2*B*a*b*c+C*a^2*c)/f*(tan(f*x+e)-arctan(tan(f*x 
+e)))+A*a^2*c*x+d*C*b^2/f*(1/4*tan(f*x+e)^4-1/2*tan(f*x+e)^2+1/2*ln(1+tan( 
f*x+e)^2))
 

Fricas [A] (verification not implemented)

Time = 0.09 (sec) , antiderivative size = 273, normalized size of antiderivative = 1.10 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {3 \, C b^{2} d \tan \left (f x + e\right )^{4} + 4 \, {\left (C b^{2} c + {\left (2 \, C a b + B b^{2}\right )} d\right )} \tan \left (f x + e\right )^{3} + 12 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c - {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} f x + 6 \, {\left ({\left (2 \, C a b + B b^{2}\right )} c + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d\right )} \tan \left (f x + e\right )^{2} - 6 \, {\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c + {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d\right )} \log \left (\frac {1}{\tan \left (f x + e\right )^{2} + 1}\right ) + 12 \, {\left ({\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} \tan \left (f x + e\right )}{12 \, f} \] Input:

integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e) 
^2),x, algorithm="fricas")
 

Output:

1/12*(3*C*b^2*d*tan(f*x + e)^4 + 4*(C*b^2*c + (2*C*a*b + B*b^2)*d)*tan(f*x 
 + e)^3 + 12*(((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*c - (B*a^2 + 2*(A - C) 
*a*b - B*b^2)*d)*f*x + 6*((2*C*a*b + B*b^2)*c + (C*a^2 + 2*B*a*b + (A - C) 
*b^2)*d)*tan(f*x + e)^2 - 6*((B*a^2 + 2*(A - C)*a*b - B*b^2)*c + ((A - C)* 
a^2 - 2*B*a*b - (A - C)*b^2)*d)*log(1/(tan(f*x + e)^2 + 1)) + 12*((C*a^2 + 
 2*B*a*b + (A - C)*b^2)*c + (B*a^2 + 2*(A - C)*a*b - B*b^2)*d)*tan(f*x + e 
))/f
 

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 617 vs. \(2 (218) = 436\).

Time = 0.21 (sec) , antiderivative size = 617, normalized size of antiderivative = 2.49 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx =\text {Too large to display} \] Input:

integrate((a+b*tan(f*x+e))**2*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e 
)**2),x)
 

Output:

Piecewise((A*a**2*c*x + A*a**2*d*log(tan(e + f*x)**2 + 1)/(2*f) + A*a*b*c* 
log(tan(e + f*x)**2 + 1)/f - 2*A*a*b*d*x + 2*A*a*b*d*tan(e + f*x)/f - A*b* 
*2*c*x + A*b**2*c*tan(e + f*x)/f - A*b**2*d*log(tan(e + f*x)**2 + 1)/(2*f) 
 + A*b**2*d*tan(e + f*x)**2/(2*f) + B*a**2*c*log(tan(e + f*x)**2 + 1)/(2*f 
) - B*a**2*d*x + B*a**2*d*tan(e + f*x)/f - 2*B*a*b*c*x + 2*B*a*b*c*tan(e + 
 f*x)/f - B*a*b*d*log(tan(e + f*x)**2 + 1)/f + B*a*b*d*tan(e + f*x)**2/f - 
 B*b**2*c*log(tan(e + f*x)**2 + 1)/(2*f) + B*b**2*c*tan(e + f*x)**2/(2*f) 
+ B*b**2*d*x + B*b**2*d*tan(e + f*x)**3/(3*f) - B*b**2*d*tan(e + f*x)/f - 
C*a**2*c*x + C*a**2*c*tan(e + f*x)/f - C*a**2*d*log(tan(e + f*x)**2 + 1)/( 
2*f) + C*a**2*d*tan(e + f*x)**2/(2*f) - C*a*b*c*log(tan(e + f*x)**2 + 1)/f 
 + C*a*b*c*tan(e + f*x)**2/f + 2*C*a*b*d*x + 2*C*a*b*d*tan(e + f*x)**3/(3* 
f) - 2*C*a*b*d*tan(e + f*x)/f + C*b**2*c*x + C*b**2*c*tan(e + f*x)**3/(3*f 
) - C*b**2*c*tan(e + f*x)/f + C*b**2*d*log(tan(e + f*x)**2 + 1)/(2*f) + C* 
b**2*d*tan(e + f*x)**4/(4*f) - C*b**2*d*tan(e + f*x)**2/(2*f), Ne(f, 0)), 
(x*(a + b*tan(e))**2*(c + d*tan(e))*(A + B*tan(e) + C*tan(e)**2), True))
 

Maxima [A] (verification not implemented)

Time = 0.11 (sec) , antiderivative size = 274, normalized size of antiderivative = 1.10 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {3 \, C b^{2} d \tan \left (f x + e\right )^{4} + 4 \, {\left (C b^{2} c + {\left (2 \, C a b + B b^{2}\right )} d\right )} \tan \left (f x + e\right )^{3} + 6 \, {\left ({\left (2 \, C a b + B b^{2}\right )} c + {\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} d\right )} \tan \left (f x + e\right )^{2} + 12 \, {\left ({\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} c - {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} {\left (f x + e\right )} + 6 \, {\left ({\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} c + {\left ({\left (A - C\right )} a^{2} - 2 \, B a b - {\left (A - C\right )} b^{2}\right )} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right ) + 12 \, {\left ({\left (C a^{2} + 2 \, B a b + {\left (A - C\right )} b^{2}\right )} c + {\left (B a^{2} + 2 \, {\left (A - C\right )} a b - B b^{2}\right )} d\right )} \tan \left (f x + e\right )}{12 \, f} \] Input:

integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e) 
^2),x, algorithm="maxima")
 

Output:

1/12*(3*C*b^2*d*tan(f*x + e)^4 + 4*(C*b^2*c + (2*C*a*b + B*b^2)*d)*tan(f*x 
 + e)^3 + 6*((2*C*a*b + B*b^2)*c + (C*a^2 + 2*B*a*b + (A - C)*b^2)*d)*tan( 
f*x + e)^2 + 12*(((A - C)*a^2 - 2*B*a*b - (A - C)*b^2)*c - (B*a^2 + 2*(A - 
 C)*a*b - B*b^2)*d)*(f*x + e) + 6*((B*a^2 + 2*(A - C)*a*b - B*b^2)*c + ((A 
 - C)*a^2 - 2*B*a*b - (A - C)*b^2)*d)*log(tan(f*x + e)^2 + 1) + 12*((C*a^2 
 + 2*B*a*b + (A - C)*b^2)*c + (B*a^2 + 2*(A - C)*a*b - B*b^2)*d)*tan(f*x + 
 e))/f
 

Giac [A] (verification not implemented)

Time = 0.73 (sec) , antiderivative size = 450, normalized size of antiderivative = 1.81 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {{\left (A a^{2} c - C a^{2} c - 2 \, B a b c - A b^{2} c + C b^{2} c - B a^{2} d - 2 \, A a b d + 2 \, C a b d + B b^{2} d\right )} {\left (f x + e\right )}}{f} + \frac {{\left (B a^{2} c + 2 \, A a b c - 2 \, C a b c - B b^{2} c + A a^{2} d - C a^{2} d - 2 \, B a b d - A b^{2} d + C b^{2} d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{2 \, f} + \frac {3 \, C b^{2} d f^{3} \tan \left (f x + e\right )^{4} + 4 \, C b^{2} c f^{3} \tan \left (f x + e\right )^{3} + 8 \, C a b d f^{3} \tan \left (f x + e\right )^{3} + 4 \, B b^{2} d f^{3} \tan \left (f x + e\right )^{3} + 12 \, C a b c f^{3} \tan \left (f x + e\right )^{2} + 6 \, B b^{2} c f^{3} \tan \left (f x + e\right )^{2} + 6 \, C a^{2} d f^{3} \tan \left (f x + e\right )^{2} + 12 \, B a b d f^{3} \tan \left (f x + e\right )^{2} + 6 \, A b^{2} d f^{3} \tan \left (f x + e\right )^{2} - 6 \, C b^{2} d f^{3} \tan \left (f x + e\right )^{2} + 12 \, C a^{2} c f^{3} \tan \left (f x + e\right ) + 24 \, B a b c f^{3} \tan \left (f x + e\right ) + 12 \, A b^{2} c f^{3} \tan \left (f x + e\right ) - 12 \, C b^{2} c f^{3} \tan \left (f x + e\right ) + 12 \, B a^{2} d f^{3} \tan \left (f x + e\right ) + 24 \, A a b d f^{3} \tan \left (f x + e\right ) - 24 \, C a b d f^{3} \tan \left (f x + e\right ) - 12 \, B b^{2} d f^{3} \tan \left (f x + e\right )}{12 \, f^{4}} \] Input:

integrate((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e) 
^2),x, algorithm="giac")
 

Output:

(A*a^2*c - C*a^2*c - 2*B*a*b*c - A*b^2*c + C*b^2*c - B*a^2*d - 2*A*a*b*d + 
 2*C*a*b*d + B*b^2*d)*(f*x + e)/f + 1/2*(B*a^2*c + 2*A*a*b*c - 2*C*a*b*c - 
 B*b^2*c + A*a^2*d - C*a^2*d - 2*B*a*b*d - A*b^2*d + C*b^2*d)*log(tan(f*x 
+ e)^2 + 1)/f + 1/12*(3*C*b^2*d*f^3*tan(f*x + e)^4 + 4*C*b^2*c*f^3*tan(f*x 
 + e)^3 + 8*C*a*b*d*f^3*tan(f*x + e)^3 + 4*B*b^2*d*f^3*tan(f*x + e)^3 + 12 
*C*a*b*c*f^3*tan(f*x + e)^2 + 6*B*b^2*c*f^3*tan(f*x + e)^2 + 6*C*a^2*d*f^3 
*tan(f*x + e)^2 + 12*B*a*b*d*f^3*tan(f*x + e)^2 + 6*A*b^2*d*f^3*tan(f*x + 
e)^2 - 6*C*b^2*d*f^3*tan(f*x + e)^2 + 12*C*a^2*c*f^3*tan(f*x + e) + 24*B*a 
*b*c*f^3*tan(f*x + e) + 12*A*b^2*c*f^3*tan(f*x + e) - 12*C*b^2*c*f^3*tan(f 
*x + e) + 12*B*a^2*d*f^3*tan(f*x + e) + 24*A*a*b*d*f^3*tan(f*x + e) - 24*C 
*a*b*d*f^3*tan(f*x + e) - 12*B*b^2*d*f^3*tan(f*x + e))/f^4
 

Mupad [B] (verification not implemented)

Time = 5.54 (sec) , antiderivative size = 300, normalized size of antiderivative = 1.21 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {{\mathrm {tan}\left (e+f\,x\right )}^2\,\left (\frac {A\,b^2\,d}{2}+\frac {B\,b^2\,c}{2}+\frac {C\,a^2\,d}{2}-\frac {C\,b^2\,d}{2}+B\,a\,b\,d+C\,a\,b\,c\right )}{f}-x\,\left (A\,b^2\,c-A\,a^2\,c+B\,a^2\,d+C\,a^2\,c-B\,b^2\,d-C\,b^2\,c+2\,A\,a\,b\,d+2\,B\,a\,b\,c-2\,C\,a\,b\,d\right )-\frac {\ln \left ({\mathrm {tan}\left (e+f\,x\right )}^2+1\right )\,\left (\frac {A\,b^2\,d}{2}-\frac {B\,a^2\,c}{2}-\frac {A\,a^2\,d}{2}+\frac {B\,b^2\,c}{2}+\frac {C\,a^2\,d}{2}-\frac {C\,b^2\,d}{2}-A\,a\,b\,c+B\,a\,b\,d+C\,a\,b\,c\right )}{f}+\frac {\mathrm {tan}\left (e+f\,x\right )\,\left (A\,b^2\,c+B\,a^2\,d+C\,a^2\,c-B\,b^2\,d-C\,b^2\,c+2\,A\,a\,b\,d+2\,B\,a\,b\,c-2\,C\,a\,b\,d\right )}{f}+\frac {{\mathrm {tan}\left (e+f\,x\right )}^3\,\left (\frac {B\,b^2\,d}{3}+\frac {C\,b^2\,c}{3}+\frac {2\,C\,a\,b\,d}{3}\right )}{f}+\frac {C\,b^2\,d\,{\mathrm {tan}\left (e+f\,x\right )}^4}{4\,f} \] Input:

int((a + b*tan(e + f*x))^2*(c + d*tan(e + f*x))*(A + B*tan(e + f*x) + C*ta 
n(e + f*x)^2),x)
 

Output:

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

Reduce [B] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 403, normalized size of antiderivative = 1.62 \[ \int (a+b \tan (e+f x))^2 (c+d \tan (e+f x)) \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right ) \, dx=\frac {-6 \tan \left (f x +e \right )^{2} b^{2} c d +24 a b c d f x -12 \tan \left (f x +e \right ) b^{2} c^{2}-24 \tan \left (f x +e \right ) a b c d +18 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a^{2} b c -6 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a^{2} c d -18 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a \,b^{2} d -12 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a b \,c^{2}+6 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b^{2} c d +3 \tan \left (f x +e \right )^{4} b^{2} c d +6 \tan \left (f x +e \right )^{2} a^{2} c d +18 \tan \left (f x +e \right )^{2} a \,b^{2} d +12 \tan \left (f x +e \right )^{2} a b \,c^{2}+36 \tan \left (f x +e \right ) a^{2} b d +36 \tan \left (f x +e \right ) a \,b^{2} c +12 a^{3} c f x -12 a^{2} c^{2} f x +12 b^{3} d f x +12 b^{2} c^{2} f x +6 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a^{3} d -6 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b^{3} c +4 \tan \left (f x +e \right )^{3} b^{3} d +4 \tan \left (f x +e \right )^{3} b^{2} c^{2}+6 \tan \left (f x +e \right )^{2} b^{3} c +12 \tan \left (f x +e \right ) a^{2} c^{2}-12 \tan \left (f x +e \right ) b^{3} d +8 \tan \left (f x +e \right )^{3} a b c d -36 a^{2} b d f x -36 a \,b^{2} c f x}{12 f} \] Input:

int((a+b*tan(f*x+e))^2*(c+d*tan(f*x+e))*(A+B*tan(f*x+e)+C*tan(f*x+e)^2),x)
 

Output:

(6*log(tan(e + f*x)**2 + 1)*a**3*d + 18*log(tan(e + f*x)**2 + 1)*a**2*b*c 
- 6*log(tan(e + f*x)**2 + 1)*a**2*c*d - 18*log(tan(e + f*x)**2 + 1)*a*b**2 
*d - 12*log(tan(e + f*x)**2 + 1)*a*b*c**2 - 6*log(tan(e + f*x)**2 + 1)*b** 
3*c + 6*log(tan(e + f*x)**2 + 1)*b**2*c*d + 3*tan(e + f*x)**4*b**2*c*d + 8 
*tan(e + f*x)**3*a*b*c*d + 4*tan(e + f*x)**3*b**3*d + 4*tan(e + f*x)**3*b* 
*2*c**2 + 6*tan(e + f*x)**2*a**2*c*d + 18*tan(e + f*x)**2*a*b**2*d + 12*ta 
n(e + f*x)**2*a*b*c**2 + 6*tan(e + f*x)**2*b**3*c - 6*tan(e + f*x)**2*b**2 
*c*d + 36*tan(e + f*x)*a**2*b*d + 12*tan(e + f*x)*a**2*c**2 + 36*tan(e + f 
*x)*a*b**2*c - 24*tan(e + f*x)*a*b*c*d - 12*tan(e + f*x)*b**3*d - 12*tan(e 
 + f*x)*b**2*c**2 + 12*a**3*c*f*x - 36*a**2*b*d*f*x - 12*a**2*c**2*f*x - 3 
6*a*b**2*c*f*x + 24*a*b*c*d*f*x + 12*b**3*d*f*x + 12*b**2*c**2*f*x)/(12*f)