\(\int \frac {(c+d \tan (e+f x))^3 (A+B \tan (e+f x)+C \tan ^2(e+f x))}{a+b \tan (e+f x)} \, dx\) [67]

Optimal result
Mathematica [C] (verified)
Rubi [A] (verified)
Maple [A] (verified)
Fricas [A] (verification not implemented)
Sympy [C] (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 = 45, antiderivative size = 363 \[ \int \frac {(c+d \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=-\frac {\left (a \left (c^3 C+3 B c^2 d-3 c C d^2-B d^3-A \left (c^3-3 c d^2\right )\right )-b \left ((A-C) d \left (3 c^2-d^2\right )+B \left (c^3-3 c d^2\right )\right )\right ) x}{a^2+b^2}-\frac {\left (b \left (c^3 C+3 B c^2 d-3 c C d^2-B d^3\right )+a \left (B c^3-3 c^2 C d-3 B c d^2+C d^3\right )+A \left (a d \left (3 c^2-d^2\right )-b \left (c^3-3 c d^2\right )\right )\right ) \log (\cos (e+f x))}{\left (a^2+b^2\right ) f}+\frac {\left (A b^2-a (b B-a C)\right ) (b c-a d)^3 \log (a+b \tan (e+f x))}{b^4 \left (a^2+b^2\right ) f}+\frac {d \left (b^2 d (B c+(A-C) d)+(b c-a d) (b c C+b B d-a C d)\right ) \tan (e+f x)}{b^3 f}+\frac {(b c C+b B d-a C d) (c+d \tan (e+f x))^2}{2 b^2 f}+\frac {C (c+d \tan (e+f x))^3}{3 b f} \] Output:

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

Mathematica [C] (verified)

Result contains complex when optimal does not.

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

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

Output:

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

Rubi [A] (verified)

Time = 4.02 (sec) , antiderivative size = 387, normalized size of antiderivative = 1.07, number of steps used = 16, number of rules used = 15, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {3042, 4130, 27, 3042, 4130, 27, 3042, 4120, 25, 3042, 4109, 3042, 3956, 4100, 16}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4130

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4130

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4120

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

\(\Big \downarrow \) 25

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4109

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3956

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

\(\Big \downarrow \) 4100

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

\(\Big \downarrow \) 16

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

Input:

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

Output:

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

Defintions of rubi rules used

rule 16
Int[(c_.)/((a_.) + (b_.)*(x_)), x_Symbol] :> Simp[c*(Log[RemoveContent[a + 
b*x, x]]/b), x] /; FreeQ[{a, b, c}, x]
 

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, 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 4100
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + 
 (f_.)*(x_)]^2), x_Symbol] :> Simp[A/(b*f)   Subst[Int[(a + x)^m, x], x, b* 
Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]
 

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

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]
 

rule 4130
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) 
+ (f_.)*(x_)])^(n_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_. 
) + (f_.)*(x_)]^2), x_Symbol] :> Simp[C*(a + b*Tan[e + f*x])^m*((c + d*Tan[ 
e + f*x])^(n + 1)/(d*f*(m + n + 1))), x] + Simp[1/(d*(m + n + 1))   Int[(a 
+ b*Tan[e + f*x])^(m - 1)*(c + d*Tan[e + f*x])^n*Simp[a*A*d*(m + n + 1) - C 
*(b*c*m + a*d*(n + 1)) + d*(A*b + a*B - b*C)*(m + n + 1)*Tan[e + f*x] - (C* 
m*(b*c - a*d) - b*B*d*(m + n + 1))*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[a^2 + b^2, 0] && 
 NeQ[c^2 + d^2, 0] && GtQ[m, 0] &&  !(IGtQ[n, 0] && ( !IntegerQ[m] || (EqQ[ 
c, 0] && NeQ[a, 0])))
 
Maple [A] (verified)

Time = 0.27 (sec) , antiderivative size = 501, normalized size of antiderivative = 1.38

method result size
norman \(\frac {\left (A a \,c^{3}-3 A a c \,d^{2}+3 A b \,c^{2} d -A b \,d^{3}-3 B a \,c^{2} d +B a \,d^{3}+B b \,c^{3}-3 B b c \,d^{2}-C a \,c^{3}+3 C a c \,d^{2}-3 C b \,c^{2} d +C b \,d^{3}\right ) x}{a^{2}+b^{2}}+\frac {\left (A \,b^{2} d^{2}-B a b \,d^{2}+3 B \,b^{2} c d +a^{2} C \,d^{2}-3 C a b c d +3 C \,b^{2} c^{2}-b^{2} d^{2} C \right ) d \tan \left (f x +e \right )}{f \,b^{3}}+\frac {C \,d^{3} \tan \left (f x +e \right )^{3}}{3 f b}+\frac {d^{2} \left (B b d -C a d +3 C b c \right ) \tan \left (f x +e \right )^{2}}{2 b^{2} f}+\frac {\left (3 A a \,c^{2} d -A a \,d^{3}-A b \,c^{3}+3 A b c \,d^{2}+B a \,c^{3}-3 B a c \,d^{2}+3 B b \,c^{2} d -B b \,d^{3}-3 C a \,c^{2} d +C a \,d^{3}+C b \,c^{3}-3 C b c \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2 f \left (a^{2}+b^{2}\right )}-\frac {\left (A \,a^{3} d^{3} b^{2}-3 A \,b^{3} c \,d^{2} a^{2}+3 A \,b^{4} c^{2} d a -A \,b^{5} c^{3}-B \,a^{4} d^{3} b +3 B \,a^{3} c \,d^{2} b^{2}-3 B \,b^{3} c^{2} d \,a^{2}+B \,b^{4} c^{3} a +a^{5} C \,d^{3}-3 C \,a^{4} c \,d^{2} b +3 C \,a^{3} c^{2} d \,b^{2}-C \,b^{3} c^{3} a^{2}\right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right ) b^{4} f}\) \(501\)
derivativedivides \(\frac {\frac {d \left (\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}-\frac {C a b \,d^{2} \tan \left (f x +e \right )^{2}}{2}+\frac {3 C \,b^{2} c d \tan \left (f x +e \right )^{2}}{2}+\tan \left (f x +e \right ) A \,b^{2} d^{2}-\tan \left (f x +e \right ) B a b \,d^{2}+3 \tan \left (f x +e \right ) B \,b^{2} c d +\tan \left (f x +e \right ) a^{2} C \,d^{2}-3 \tan \left (f x +e \right ) C a b c d +3 \tan \left (f x +e \right ) C \,b^{2} c^{2}-\tan \left (f x +e \right ) b^{2} d^{2} C \right )}{b^{3}}+\frac {\frac {\left (3 A a \,c^{2} d -A a \,d^{3}-A b \,c^{3}+3 A b c \,d^{2}+B a \,c^{3}-3 B a c \,d^{2}+3 B b \,c^{2} d -B b \,d^{3}-3 C a \,c^{2} d +C a \,d^{3}+C b \,c^{3}-3 C b c \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A a \,c^{3}-3 A a c \,d^{2}+3 A b \,c^{2} d -A b \,d^{3}-3 B a \,c^{2} d +B a \,d^{3}+B b \,c^{3}-3 B b c \,d^{2}-C a \,c^{3}+3 C a c \,d^{2}-3 C b \,c^{2} d +C b \,d^{3}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{a^{2}+b^{2}}+\frac {\left (-A \,a^{3} d^{3} b^{2}+3 A \,b^{3} c \,d^{2} a^{2}-3 A \,b^{4} c^{2} d a +A \,b^{5} c^{3}+B \,a^{4} d^{3} b -3 B \,a^{3} c \,d^{2} b^{2}+3 B \,b^{3} c^{2} d \,a^{2}-B \,b^{4} c^{3} a -a^{5} C \,d^{3}+3 C \,a^{4} c \,d^{2} b -3 C \,a^{3} c^{2} d \,b^{2}+C \,b^{3} c^{3} a^{2}\right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{b^{4} \left (a^{2}+b^{2}\right )}}{f}\) \(542\)
default \(\frac {\frac {d \left (\frac {C \,b^{2} d^{2} \tan \left (f x +e \right )^{3}}{3}+\frac {B \,b^{2} d^{2} \tan \left (f x +e \right )^{2}}{2}-\frac {C a b \,d^{2} \tan \left (f x +e \right )^{2}}{2}+\frac {3 C \,b^{2} c d \tan \left (f x +e \right )^{2}}{2}+\tan \left (f x +e \right ) A \,b^{2} d^{2}-\tan \left (f x +e \right ) B a b \,d^{2}+3 \tan \left (f x +e \right ) B \,b^{2} c d +\tan \left (f x +e \right ) a^{2} C \,d^{2}-3 \tan \left (f x +e \right ) C a b c d +3 \tan \left (f x +e \right ) C \,b^{2} c^{2}-\tan \left (f x +e \right ) b^{2} d^{2} C \right )}{b^{3}}+\frac {\frac {\left (3 A a \,c^{2} d -A a \,d^{3}-A b \,c^{3}+3 A b c \,d^{2}+B a \,c^{3}-3 B a c \,d^{2}+3 B b \,c^{2} d -B b \,d^{3}-3 C a \,c^{2} d +C a \,d^{3}+C b \,c^{3}-3 C b c \,d^{2}\right ) \ln \left (1+\tan \left (f x +e \right )^{2}\right )}{2}+\left (A a \,c^{3}-3 A a c \,d^{2}+3 A b \,c^{2} d -A b \,d^{3}-3 B a \,c^{2} d +B a \,d^{3}+B b \,c^{3}-3 B b c \,d^{2}-C a \,c^{3}+3 C a c \,d^{2}-3 C b \,c^{2} d +C b \,d^{3}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{a^{2}+b^{2}}+\frac {\left (-A \,a^{3} d^{3} b^{2}+3 A \,b^{3} c \,d^{2} a^{2}-3 A \,b^{4} c^{2} d a +A \,b^{5} c^{3}+B \,a^{4} d^{3} b -3 B \,a^{3} c \,d^{2} b^{2}+3 B \,b^{3} c^{2} d \,a^{2}-B \,b^{4} c^{3} a -a^{5} C \,d^{3}+3 C \,a^{4} c \,d^{2} b -3 C \,a^{3} c^{2} d \,b^{2}+C \,b^{3} c^{3} a^{2}\right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{b^{4} \left (a^{2}+b^{2}\right )}}{f}\) \(542\)
parallelrisch \(\text {Expression too large to display}\) \(1038\)
risch \(\text {Expression too large to display}\) \(2490\)

Input:

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

Output:

(A*a*c^3-3*A*a*c*d^2+3*A*b*c^2*d-A*b*d^3-3*B*a*c^2*d+B*a*d^3+B*b*c^3-3*B*b 
*c*d^2-C*a*c^3+3*C*a*c*d^2-3*C*b*c^2*d+C*b*d^3)/(a^2+b^2)*x+(A*b^2*d^2-B*a 
*b*d^2+3*B*b^2*c*d+C*a^2*d^2-3*C*a*b*c*d+3*C*b^2*c^2-C*b^2*d^2)*d/f/b^3*ta 
n(f*x+e)+1/3*C*d^3/f/b*tan(f*x+e)^3+1/2*d^2*(B*b*d-C*a*d+3*C*b*c)/b^2/f*ta 
n(f*x+e)^2+1/2*(3*A*a*c^2*d-A*a*d^3-A*b*c^3+3*A*b*c*d^2+B*a*c^3-3*B*a*c*d^ 
2+3*B*b*c^2*d-B*b*d^3-3*C*a*c^2*d+C*a*d^3+C*b*c^3-3*C*b*c*d^2)/f/(a^2+b^2) 
*ln(1+tan(f*x+e)^2)-(A*a^3*b^2*d^3-3*A*a^2*b^3*c*d^2+3*A*a*b^4*c^2*d-A*b^5 
*c^3-B*a^4*b*d^3+3*B*a^3*b^2*c*d^2-3*B*a^2*b^3*c^2*d+B*a*b^4*c^3+C*a^5*d^3 
-3*C*a^4*b*c*d^2+3*C*a^3*b^2*c^2*d-C*a^2*b^3*c^3)/(a^2+b^2)/b^4/f*ln(a+b*t 
an(f*x+e))
 

Fricas [A] (verification not implemented)

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

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

Output:

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

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

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

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

Output:

Piecewise((zoo*x*(c + d*tan(e))**3*(A + B*tan(e) + C*tan(e)**2)/tan(e), Eq 
(a, 0) & Eq(b, 0) & Eq(f, 0)), ((A*c**3*x + 3*A*c**2*d*log(tan(e + f*x)**2 
 + 1)/(2*f) - 3*A*c*d**2*x + 3*A*c*d**2*tan(e + f*x)/f - A*d**3*log(tan(e 
+ f*x)**2 + 1)/(2*f) + A*d**3*tan(e + f*x)**2/(2*f) + B*c**3*log(tan(e + f 
*x)**2 + 1)/(2*f) - 3*B*c**2*d*x + 3*B*c**2*d*tan(e + f*x)/f - 3*B*c*d**2* 
log(tan(e + f*x)**2 + 1)/(2*f) + 3*B*c*d**2*tan(e + f*x)**2/(2*f) + B*d**3 
*x + B*d**3*tan(e + f*x)**3/(3*f) - B*d**3*tan(e + f*x)/f - C*c**3*x + C*c 
**3*tan(e + f*x)/f - 3*C*c**2*d*log(tan(e + f*x)**2 + 1)/(2*f) + 3*C*c**2* 
d*tan(e + f*x)**2/(2*f) + 3*C*c*d**2*x + C*c*d**2*tan(e + f*x)**3/f - 3*C* 
c*d**2*tan(e + f*x)/f + C*d**3*log(tan(e + f*x)**2 + 1)/(2*f) + C*d**3*tan 
(e + f*x)**4/(4*f) - C*d**3*tan(e + f*x)**2/(2*f))/a, Eq(b, 0)), (3*I*A*c* 
*3*f*x*tan(e + f*x)/(6*b*f*tan(e + f*x) - 6*I*b*f) + 3*A*c**3*f*x/(6*b*f*t 
an(e + f*x) - 6*I*b*f) + 3*I*A*c**3/(6*b*f*tan(e + f*x) - 6*I*b*f) + 9*A*c 
**2*d*f*x*tan(e + f*x)/(6*b*f*tan(e + f*x) - 6*I*b*f) - 9*I*A*c**2*d*f*x/( 
6*b*f*tan(e + f*x) - 6*I*b*f) - 9*A*c**2*d/(6*b*f*tan(e + f*x) - 6*I*b*f) 
+ 9*I*A*c*d**2*f*x*tan(e + f*x)/(6*b*f*tan(e + f*x) - 6*I*b*f) + 9*A*c*d** 
2*f*x/(6*b*f*tan(e + f*x) - 6*I*b*f) + 9*A*c*d**2*log(tan(e + f*x)**2 + 1) 
*tan(e + f*x)/(6*b*f*tan(e + f*x) - 6*I*b*f) - 9*I*A*c*d**2*log(tan(e + f* 
x)**2 + 1)/(6*b*f*tan(e + f*x) - 6*I*b*f) - 9*I*A*c*d**2/(6*b*f*tan(e + f* 
x) - 6*I*b*f) - 9*A*d**3*f*x*tan(e + f*x)/(6*b*f*tan(e + f*x) - 6*I*b*f...
 

Maxima [A] (verification not implemented)

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

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.71 (sec) , antiderivative size = 600, normalized size of antiderivative = 1.65 \[ \int \frac {(c+d \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\frac {{\left (A a c^{3} - C a c^{3} + B b c^{3} - 3 \, B a c^{2} d + 3 \, A b c^{2} d - 3 \, C b c^{2} d - 3 \, A a c d^{2} + 3 \, C a c d^{2} - 3 \, B b c d^{2} + B a d^{3} - A b d^{3} + C b d^{3}\right )} {\left (f x + e\right )}}{a^{2} f + b^{2} f} + \frac {{\left (B a c^{3} - A b c^{3} + C b c^{3} + 3 \, A a c^{2} d - 3 \, C a c^{2} d + 3 \, B b c^{2} d - 3 \, B a c d^{2} + 3 \, A b c d^{2} - 3 \, C b c d^{2} - A a d^{3} + C a d^{3} - B b d^{3}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{2 \, {\left (a^{2} f + b^{2} f\right )}} + \frac {{\left (C a^{2} b^{3} c^{3} - B a b^{4} c^{3} + A b^{5} c^{3} - 3 \, C a^{3} b^{2} c^{2} d + 3 \, B a^{2} b^{3} c^{2} d - 3 \, A a b^{4} c^{2} d + 3 \, C a^{4} b c d^{2} - 3 \, B a^{3} b^{2} c d^{2} + 3 \, A a^{2} b^{3} c d^{2} - C a^{5} d^{3} + B a^{4} b d^{3} - A a^{3} b^{2} d^{3}\right )} \log \left ({\left | b \tan \left (f x + e\right ) + a \right |}\right )}{a^{2} b^{4} f + b^{6} f} + \frac {2 \, C b^{2} d^{3} f^{2} \tan \left (f x + e\right )^{3} + 9 \, C b^{2} c d^{2} f^{2} \tan \left (f x + e\right )^{2} - 3 \, C a b d^{3} f^{2} \tan \left (f x + e\right )^{2} + 3 \, B b^{2} d^{3} f^{2} \tan \left (f x + e\right )^{2} + 18 \, C b^{2} c^{2} d f^{2} \tan \left (f x + e\right ) - 18 \, C a b c d^{2} f^{2} \tan \left (f x + e\right ) + 18 \, B b^{2} c d^{2} f^{2} \tan \left (f x + e\right ) + 6 \, C a^{2} d^{3} f^{2} \tan \left (f x + e\right ) - 6 \, B a b d^{3} f^{2} \tan \left (f x + e\right ) + 6 \, A b^{2} d^{3} f^{2} \tan \left (f x + e\right ) - 6 \, C b^{2} d^{3} f^{2} \tan \left (f x + e\right )}{6 \, b^{3} f^{3}} \] Input:

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

Output:

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

Mupad [B] (verification not implemented)

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

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

Output:

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

Reduce [B] (verification not implemented)

Time = 0.17 (sec) , antiderivative size = 654, normalized size of antiderivative = 1.80 \[ \int \frac {(c+d \tan (e+f x))^3 \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{a+b \tan (e+f x)} \, dx=\frac {-18 a^{2} b^{4} c \,d^{2} f x +18 a \,b^{4} c^{2} d^{2} f x -3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a^{2} b^{4} d^{3}+9 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b^{6} c^{2} d -9 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b^{5} c^{2} d^{2}-6 \,\mathrm {log}\left (\tan \left (f x +e \right ) b +a \right ) a^{5} c \,d^{3}+6 \,\mathrm {log}\left (\tan \left (f x +e \right ) b +a \right ) a^{2} b^{3} c^{4}+2 \tan \left (f x +e \right )^{3} b^{5} c \,d^{3}+3 \tan \left (f x +e \right )^{2} a^{2} b^{4} d^{3}+9 \tan \left (f x +e \right )^{2} b^{5} c^{2} d^{2}+18 \tan \left (f x +e \right ) b^{6} c \,d^{2}+18 \tan \left (f x +e \right ) b^{5} c^{3} d -6 \tan \left (f x +e \right ) b^{5} c \,d^{3}+6 b^{6} c^{3} f x +9 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a^{2} b^{4} c^{2} d -9 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a \,b^{4} c^{3} d +3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) a \,b^{4} c \,d^{3}+18 \,\mathrm {log}\left (\tan \left (f x +e \right ) b +a \right ) a^{4} b \,c^{2} d^{2}-18 \,\mathrm {log}\left (\tan \left (f x +e \right ) b +a \right ) a^{3} b^{2} c^{3} d +2 \tan \left (f x +e \right )^{3} a^{2} b^{3} c \,d^{3}-3 \tan \left (f x +e \right )^{2} a^{3} b^{2} c \,d^{3}+9 \tan \left (f x +e \right )^{2} a^{2} b^{3} c^{2} d^{2}-3 \tan \left (f x +e \right )^{2} a \,b^{4} c \,d^{3}+6 \tan \left (f x +e \right ) a^{4} b c \,d^{3}-18 \tan \left (f x +e \right ) a^{3} b^{2} c^{2} d^{2}+18 \tan \left (f x +e \right ) a^{2} b^{4} c \,d^{2}+18 \tan \left (f x +e \right ) a^{2} b^{3} c^{3} d -18 \tan \left (f x +e \right ) a \,b^{4} c^{2} d^{2}+6 a^{2} b^{4} c^{3} f x -6 a \,b^{4} c^{4} f x -18 b^{6} c \,d^{2} f x -18 b^{5} c^{3} d f x +6 b^{5} c \,d^{3} f x -3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b^{6} d^{3}+3 \,\mathrm {log}\left (\tan \left (f x +e \right )^{2}+1\right ) b^{5} c^{4}+3 \tan \left (f x +e \right )^{2} b^{6} d^{3}}{6 b^{4} f \left (a^{2}+b^{2}\right )} \] Input:

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

Output:

(9*log(tan(e + f*x)**2 + 1)*a**2*b**4*c**2*d - 3*log(tan(e + f*x)**2 + 1)* 
a**2*b**4*d**3 - 9*log(tan(e + f*x)**2 + 1)*a*b**4*c**3*d + 3*log(tan(e + 
f*x)**2 + 1)*a*b**4*c*d**3 + 9*log(tan(e + f*x)**2 + 1)*b**6*c**2*d - 3*lo 
g(tan(e + f*x)**2 + 1)*b**6*d**3 + 3*log(tan(e + f*x)**2 + 1)*b**5*c**4 - 
9*log(tan(e + f*x)**2 + 1)*b**5*c**2*d**2 - 6*log(tan(e + f*x)*b + a)*a**5 
*c*d**3 + 18*log(tan(e + f*x)*b + a)*a**4*b*c**2*d**2 - 18*log(tan(e + f*x 
)*b + a)*a**3*b**2*c**3*d + 6*log(tan(e + f*x)*b + a)*a**2*b**3*c**4 + 2*t 
an(e + f*x)**3*a**2*b**3*c*d**3 + 2*tan(e + f*x)**3*b**5*c*d**3 - 3*tan(e 
+ f*x)**2*a**3*b**2*c*d**3 + 3*tan(e + f*x)**2*a**2*b**4*d**3 + 9*tan(e + 
f*x)**2*a**2*b**3*c**2*d**2 - 3*tan(e + f*x)**2*a*b**4*c*d**3 + 3*tan(e + 
f*x)**2*b**6*d**3 + 9*tan(e + f*x)**2*b**5*c**2*d**2 + 6*tan(e + f*x)*a**4 
*b*c*d**3 - 18*tan(e + f*x)*a**3*b**2*c**2*d**2 + 18*tan(e + f*x)*a**2*b** 
4*c*d**2 + 18*tan(e + f*x)*a**2*b**3*c**3*d - 18*tan(e + f*x)*a*b**4*c**2* 
d**2 + 18*tan(e + f*x)*b**6*c*d**2 + 18*tan(e + f*x)*b**5*c**3*d - 6*tan(e 
 + f*x)*b**5*c*d**3 + 6*a**2*b**4*c**3*f*x - 18*a**2*b**4*c*d**2*f*x - 6*a 
*b**4*c**4*f*x + 18*a*b**4*c**2*d**2*f*x + 6*b**6*c**3*f*x - 18*b**6*c*d** 
2*f*x - 18*b**5*c**3*d*f*x + 6*b**5*c*d**3*f*x)/(6*b**4*f*(a**2 + b**2))