\(\int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx\) [250]

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

(A*a^3-3*A*a*b^2-3*B*a^2*b+B*b^3)*x-(3*A*a^2*b-A*b^3+B*a^3-3*B*a*b^2)*ln(c 
os(d*x+c))/d+b*(2*A*a*b+B*a^2-B*b^2)*tan(d*x+c)/d+1/2*(A*b+B*a)*(a+b*tan(d 
*x+c))^2/d+1/3*B*(a+b*tan(d*x+c))^3/d
 

Mathematica [C] (verified)

Result contains complex when optimal does not.

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

Integrate[(a + b*Tan[c + d*x])^3*(A + B*Tan[c + d*x]),x]
 

Output:

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

Rubi [A] (verified)

Time = 0.61 (sec) , antiderivative size = 140, normalized size of antiderivative = 1.00, number of steps used = 8, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.348, Rules used = {3042, 4011, 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 (c+d x))^3 (A+B \tan (c+d x)) \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x))dx\)

\(\Big \downarrow \) 4011

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4011

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4008

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3956

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

Input:

Int[(a + b*Tan[c + d*x])^3*(A + B*Tan[c + d*x]),x]
 

Output:

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

Defintions of rubi rules used

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]
 
Maple [A] (verified)

Time = 0.08 (sec) , antiderivative size = 141, normalized size of antiderivative = 1.01

method result size
norman \(\left (A \,a^{3}-3 A a \,b^{2}-3 B \,a^{2} b +B \,b^{3}\right ) x +\frac {b \left (3 A a b +3 B \,a^{2}-B \,b^{2}\right ) \tan \left (d x +c \right )}{d}+\frac {B \,b^{3} \tan \left (d x +c \right )^{3}}{3 d}+\frac {b^{2} \left (A b +3 B a \right ) \tan \left (d x +c \right )^{2}}{2 d}+\frac {\left (3 A \,a^{2} b -A \,b^{3}+B \,a^{3}-3 B a \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d}\) \(141\)
parts \(A \,a^{3} x +\frac {\left (A \,b^{3}+3 B a \,b^{2}\right ) \left (\frac {\tan \left (d x +c \right )^{2}}{2}-\frac {\ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}\right )}{d}+\frac {\left (3 A a \,b^{2}+3 B \,a^{2} b \right ) \left (\tan \left (d x +c \right )-\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}+\frac {\left (3 A \,a^{2} b +B \,a^{3}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d}+\frac {B \,b^{3} \left (\frac {\tan \left (d x +c \right )^{3}}{3}-\tan \left (d x +c \right )+\arctan \left (\tan \left (d x +c \right )\right )\right )}{d}\) \(147\)
derivativedivides \(\frac {\frac {B \,b^{3} \tan \left (d x +c \right )^{3}}{3}+\frac {A \,b^{3} \tan \left (d x +c \right )^{2}}{2}+\frac {3 B a \,b^{2} \tan \left (d x +c \right )^{2}}{2}+3 A a \,b^{2} \tan \left (d x +c \right )+3 B \,a^{2} b \tan \left (d x +c \right )-B \,b^{3} \tan \left (d x +c \right )+\frac {\left (3 A \,a^{2} b -A \,b^{3}+B \,a^{3}-3 B a \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (A \,a^{3}-3 A a \,b^{2}-3 B \,a^{2} b +B \,b^{3}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(159\)
default \(\frac {\frac {B \,b^{3} \tan \left (d x +c \right )^{3}}{3}+\frac {A \,b^{3} \tan \left (d x +c \right )^{2}}{2}+\frac {3 B a \,b^{2} \tan \left (d x +c \right )^{2}}{2}+3 A a \,b^{2} \tan \left (d x +c \right )+3 B \,a^{2} b \tan \left (d x +c \right )-B \,b^{3} \tan \left (d x +c \right )+\frac {\left (3 A \,a^{2} b -A \,b^{3}+B \,a^{3}-3 B a \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (A \,a^{3}-3 A a \,b^{2}-3 B \,a^{2} b +B \,b^{3}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{d}\) \(159\)
parallelrisch \(\frac {2 B \,b^{3} \tan \left (d x +c \right )^{3}+6 A x \,a^{3} d -18 A a \,b^{2} d x +3 A \,b^{3} \tan \left (d x +c \right )^{2}-18 B \,a^{2} b d x +6 B \,b^{3} d x +9 B a \,b^{2} \tan \left (d x +c \right )^{2}+9 A \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{2} b -3 A \ln \left (1+\tan \left (d x +c \right )^{2}\right ) b^{3}+18 A a \,b^{2} \tan \left (d x +c \right )+3 B \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{3}-9 B \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a \,b^{2}+18 B \,a^{2} b \tan \left (d x +c \right )-6 B \,b^{3} \tan \left (d x +c \right )}{6 d}\) \(192\)
risch \(A \,a^{3} x -3 A a \,b^{2} x -3 B \,a^{2} b x +B \,b^{3} x -\frac {2 i A \,b^{3} c}{d}-\frac {6 i B a \,b^{2} c}{d}+3 i A \,a^{2} b x +\frac {2 i B \,a^{3} c}{d}+\frac {6 i A \,a^{2} b c}{d}-3 i B a \,b^{2} x +\frac {2 i b \left (9 A a b \,{\mathrm e}^{4 i \left (d x +c \right )}+9 B \,a^{2} {\mathrm e}^{4 i \left (d x +c \right )}-6 B \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-3 i A \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-9 i B a b \,{\mathrm e}^{4 i \left (d x +c \right )}+18 A a b \,{\mathrm e}^{2 i \left (d x +c \right )}+18 B \,a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-6 B \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-3 i A \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-9 i B a b \,{\mathrm e}^{2 i \left (d x +c \right )}+9 A a b +9 B \,a^{2}-4 B \,b^{2}\right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}+i B \,a^{3} x -i A \,b^{3} x -\frac {3 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A \,a^{2} b}{d}+\frac {\ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) A \,b^{3}}{d}-\frac {a^{3} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B}{d}+\frac {3 \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) B a \,b^{2}}{d}\) \(383\)

Input:

int((a+b*tan(d*x+c))^3*(A+B*tan(d*x+c)),x,method=_RETURNVERBOSE)
 

Output:

(A*a^3-3*A*a*b^2-3*B*a^2*b+B*b^3)*x+b*(3*A*a*b+3*B*a^2-B*b^2)/d*tan(d*x+c) 
+1/3*B*b^3/d*tan(d*x+c)^3+1/2*b^2*(A*b+3*B*a)/d*tan(d*x+c)^2+1/2*(3*A*a^2* 
b-A*b^3+B*a^3-3*B*a*b^2)/d*ln(1+tan(d*x+c)^2)
 

Fricas [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 142, normalized size of antiderivative = 1.01 \[ \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {2 \, B b^{3} \tan \left (d x + c\right )^{3} + 6 \, {\left (A a^{3} - 3 \, B a^{2} b - 3 \, A a b^{2} + B b^{3}\right )} d x + 3 \, {\left (3 \, B a b^{2} + A b^{3}\right )} \tan \left (d x + c\right )^{2} - 3 \, {\left (B a^{3} + 3 \, A a^{2} b - 3 \, B a b^{2} - A b^{3}\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) + 6 \, {\left (3 \, B a^{2} b + 3 \, A a b^{2} - B b^{3}\right )} \tan \left (d x + c\right )}{6 \, d} \] Input:

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

Output:

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

Sympy [A] (verification not implemented)

Time = 0.14 (sec) , antiderivative size = 240, normalized size of antiderivative = 1.71 \[ \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\begin {cases} A a^{3} x + \frac {3 A a^{2} b \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 A a b^{2} x + \frac {3 A a b^{2} \tan {\left (c + d x \right )}}{d} - \frac {A b^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {A b^{3} \tan ^{2}{\left (c + d x \right )}}{2 d} + \frac {B a^{3} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} - 3 B a^{2} b x + \frac {3 B a^{2} b \tan {\left (c + d x \right )}}{d} - \frac {3 B a b^{2} \log {\left (\tan ^{2}{\left (c + d x \right )} + 1 \right )}}{2 d} + \frac {3 B a b^{2} \tan ^{2}{\left (c + d x \right )}}{2 d} + B b^{3} x + \frac {B b^{3} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac {B b^{3} \tan {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (A + B \tan {\left (c \right )}\right ) \left (a + b \tan {\left (c \right )}\right )^{3} & \text {otherwise} \end {cases} \] Input:

integrate((a+b*tan(d*x+c))**3*(A+B*tan(d*x+c)),x)
 

Output:

Piecewise((A*a**3*x + 3*A*a**2*b*log(tan(c + d*x)**2 + 1)/(2*d) - 3*A*a*b* 
*2*x + 3*A*a*b**2*tan(c + d*x)/d - A*b**3*log(tan(c + d*x)**2 + 1)/(2*d) + 
 A*b**3*tan(c + d*x)**2/(2*d) + B*a**3*log(tan(c + d*x)**2 + 1)/(2*d) - 3* 
B*a**2*b*x + 3*B*a**2*b*tan(c + d*x)/d - 3*B*a*b**2*log(tan(c + d*x)**2 + 
1)/(2*d) + 3*B*a*b**2*tan(c + d*x)**2/(2*d) + B*b**3*x + B*b**3*tan(c + d* 
x)**3/(3*d) - B*b**3*tan(c + d*x)/d, Ne(d, 0)), (x*(A + B*tan(c))*(a + b*t 
an(c))**3, True))
 

Maxima [A] (verification not implemented)

Time = 0.10 (sec) , antiderivative size = 143, normalized size of antiderivative = 1.02 \[ \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {2 \, B b^{3} \tan \left (d x + c\right )^{3} + 3 \, {\left (3 \, B a b^{2} + A b^{3}\right )} \tan \left (d x + c\right )^{2} + 6 \, {\left (A a^{3} - 3 \, B a^{2} b - 3 \, A a b^{2} + B b^{3}\right )} {\left (d x + c\right )} + 3 \, {\left (B a^{3} + 3 \, A a^{2} b - 3 \, B a b^{2} - A b^{3}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right ) + 6 \, {\left (3 \, B a^{2} b + 3 \, A a b^{2} - B b^{3}\right )} \tan \left (d x + c\right )}{6 \, d} \] Input:

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.25 (sec) , antiderivative size = 182, normalized size of antiderivative = 1.30 \[ \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {{\left (A a^{3} - 3 \, B a^{2} b - 3 \, A a b^{2} + B b^{3}\right )} {\left (d x + c\right )}}{d} + \frac {{\left (B a^{3} + 3 \, A a^{2} b - 3 \, B a b^{2} - A b^{3}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{2 \, d} + \frac {2 \, B b^{3} d^{2} \tan \left (d x + c\right )^{3} + 9 \, B a b^{2} d^{2} \tan \left (d x + c\right )^{2} + 3 \, A b^{3} d^{2} \tan \left (d x + c\right )^{2} + 18 \, B a^{2} b d^{2} \tan \left (d x + c\right ) + 18 \, A a b^{2} d^{2} \tan \left (d x + c\right ) - 6 \, B b^{3} d^{2} \tan \left (d x + c\right )}{6 \, d^{3}} \] Input:

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

Output:

(A*a^3 - 3*B*a^2*b - 3*A*a*b^2 + B*b^3)*(d*x + c)/d + 1/2*(B*a^3 + 3*A*a^2 
*b - 3*B*a*b^2 - A*b^3)*log(tan(d*x + c)^2 + 1)/d + 1/6*(2*B*b^3*d^2*tan(d 
*x + c)^3 + 9*B*a*b^2*d^2*tan(d*x + c)^2 + 3*A*b^3*d^2*tan(d*x + c)^2 + 18 
*B*a^2*b*d^2*tan(d*x + c) + 18*A*a*b^2*d^2*tan(d*x + c) - 6*B*b^3*d^2*tan( 
d*x + c))/d^3
 

Mupad [B] (verification not implemented)

Time = 3.37 (sec) , antiderivative size = 142, normalized size of antiderivative = 1.01 \[ \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=x\,\left (A\,a^3-3\,B\,a^2\,b-3\,A\,a\,b^2+B\,b^3\right )-\frac {\ln \left ({\mathrm {tan}\left (c+d\,x\right )}^2+1\right )\,\left (-\frac {B\,a^3}{2}-\frac {3\,A\,a^2\,b}{2}+\frac {3\,B\,a\,b^2}{2}+\frac {A\,b^3}{2}\right )}{d}+\frac {{\mathrm {tan}\left (c+d\,x\right )}^2\,\left (\frac {A\,b^3}{2}+\frac {3\,B\,a\,b^2}{2}\right )}{d}-\frac {\mathrm {tan}\left (c+d\,x\right )\,\left (B\,b^3-3\,a\,b\,\left (A\,b+B\,a\right )\right )}{d}+\frac {B\,b^3\,{\mathrm {tan}\left (c+d\,x\right )}^3}{3\,d} \] Input:

int((A + B*tan(c + d*x))*(a + b*tan(c + d*x))^3,x)
 

Output:

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

Reduce [B] (verification not implemented)

Time = 0.26 (sec) , antiderivative size = 115, normalized size of antiderivative = 0.82 \[ \int (a+b \tan (c+d x))^3 (A+B \tan (c+d x)) \, dx=\frac {6 \,\mathrm {log}\left (\tan \left (d x +c \right )^{2}+1\right ) a^{3} b -6 \,\mathrm {log}\left (\tan \left (d x +c \right )^{2}+1\right ) a \,b^{3}+\tan \left (d x +c \right )^{3} b^{4}+6 \tan \left (d x +c \right )^{2} a \,b^{3}+18 \tan \left (d x +c \right ) a^{2} b^{2}-3 \tan \left (d x +c \right ) b^{4}+3 a^{4} d x -18 a^{2} b^{2} d x +3 b^{4} d x}{3 d} \] Input:

int((a+b*tan(d*x+c))^3*(A+B*tan(d*x+c)),x)
 

Output:

(6*log(tan(c + d*x)**2 + 1)*a**3*b - 6*log(tan(c + d*x)**2 + 1)*a*b**3 + t 
an(c + d*x)**3*b**4 + 6*tan(c + d*x)**2*a*b**3 + 18*tan(c + d*x)*a**2*b**2 
 - 3*tan(c + d*x)*b**4 + 3*a**4*d*x - 18*a**2*b**2*d*x + 3*b**4*d*x)/(3*d)