\(\int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx\) [547]

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

Optimal result

Integrand size = 19, antiderivative size = 73 \[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {3 a b^2 \text {arctanh}(\sin (c+d x))}{d}-\frac {b \left (3 a^2-b^2\right ) \cos (c+d x)}{d}+\frac {b^3 \sec (c+d x)}{d}+\frac {a \left (a^2-3 b^2\right ) \sin (c+d x)}{d} \] Output:

3*a*b^2*arctanh(sin(d*x+c))/d-b*(3*a^2-b^2)*cos(d*x+c)/d+b^3*sec(d*x+c)/d+ 
a*(a^2-3*b^2)*sin(d*x+c)/d
 

Mathematica [A] (verified)

Time = 1.13 (sec) , antiderivative size = 131, normalized size of antiderivative = 1.79 \[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {\sec (c+d x) \left (-3 a^2 b+3 b^3+\left (-3 a^2 b+b^3\right ) \cos (2 (c+d x))-6 a b^2 \cos (c+d x) \left (\log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )-\log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+a^3 \sin (2 (c+d x))-3 a b^2 \sin (2 (c+d x))\right )}{2 d} \] Input:

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

Output:

(Sec[c + d*x]*(-3*a^2*b + 3*b^3 + (-3*a^2*b + b^3)*Cos[2*(c + d*x)] - 6*a* 
b^2*Cos[c + d*x]*(Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] - Log[Cos[(c + 
d*x)/2] + Sin[(c + d*x)/2]]) + a^3*Sin[2*(c + d*x)] - 3*a*b^2*Sin[2*(c + d 
*x)]))/(2*d)
 

Rubi [A] (verified)

Time = 0.46 (sec) , antiderivative size = 70, normalized size of antiderivative = 0.96, number of steps used = 12, number of rules used = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.579, Rules used = {3042, 3991, 3042, 4147, 27, 244, 2009, 4159, 27, 299, 219}

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 \cos (c+d x) (a+b \tan (c+d x))^3 \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(a+b \tan (c+d x))^3}{\sec (c+d x)}dx\)

\(\Big \downarrow \) 3991

\(\displaystyle \int \cos (c+d x) \left (a^3+3 b^2 \tan ^2(c+d x) a\right )dx+\int \sin (c+d x) \left (\tan ^2(c+d x) b^3+3 a^2 b\right )dx\)

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4147

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

\(\Big \downarrow \) 27

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

\(\Big \downarrow \) 244

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

\(\Big \downarrow \) 2009

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

\(\Big \downarrow \) 4159

\(\displaystyle \frac {\int \frac {a \left (a^2-\left (a^2-3 b^2\right ) \sin ^2(c+d x)\right )}{1-\sin ^2(c+d x)}d\sin (c+d x)}{d}+\frac {b \left (b^2 \sec (c+d x)-\left (3 a^2-b^2\right ) \cos (c+d x)\right )}{d}\)

\(\Big \downarrow \) 27

\(\displaystyle \frac {a \int \frac {a^2-\left (a^2-3 b^2\right ) \sin ^2(c+d x)}{1-\sin ^2(c+d x)}d\sin (c+d x)}{d}+\frac {b \left (b^2 \sec (c+d x)-\left (3 a^2-b^2\right ) \cos (c+d x)\right )}{d}\)

\(\Big \downarrow \) 299

\(\displaystyle \frac {a \left (3 b^2 \int \frac {1}{1-\sin ^2(c+d x)}d\sin (c+d x)+\left (a^2-3 b^2\right ) \sin (c+d x)\right )}{d}+\frac {b \left (b^2 \sec (c+d x)-\left (3 a^2-b^2\right ) \cos (c+d x)\right )}{d}\)

\(\Big \downarrow \) 219

\(\displaystyle \frac {a \left (\left (a^2-3 b^2\right ) \sin (c+d x)+3 b^2 \text {arctanh}(\sin (c+d x))\right )}{d}+\frac {b \left (b^2 \sec (c+d x)-\left (3 a^2-b^2\right ) \cos (c+d x)\right )}{d}\)

Input:

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

Output:

(b*(-((3*a^2 - b^2)*Cos[c + d*x]) + b^2*Sec[c + d*x]))/d + (a*(3*b^2*ArcTa 
nh[Sin[c + d*x]] + (a^2 - 3*b^2)*Sin[c + d*x]))/d
 

Defintions of rubi rules used

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 219
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))* 
ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (Gt 
Q[a, 0] || LtQ[b, 0])
 

rule 244
Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^2)^(p_.), x_Symbol] :> Int[Expand 
Integrand[(c*x)^m*(a + b*x^2)^p, x], x] /; FreeQ[{a, b, c, m}, x] && IGtQ[p 
, 0]
 

rule 299
Int[((a_) + (b_.)*(x_)^2)^(p_)*((c_) + (d_.)*(x_)^2), x_Symbol] :> Simp[d*x 
*((a + b*x^2)^(p + 1)/(b*(2*p + 3))), x] - Simp[(a*d - b*c*(2*p + 3))/(b*(2 
*p + 3))   Int[(a + b*x^2)^p, x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - 
 a*d, 0] && NeQ[2*p + 3, 0]
 

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 3991
Int[sec[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n 
_), x_Symbol] :> Module[{k}, Int[Sec[e + f*x]^m*Sum[Binomial[n, 2*k]*a^(n - 
 2*k)*b^(2*k)*Tan[e + f*x]^(2*k), {k, 0, n/2}], x] + Int[Sec[e + f*x]^m*Tan 
[e + f*x]*Sum[Binomial[n, 2*k + 1]*a^(n - 2*k - 1)*b^(2*k + 1)*Tan[e + f*x] 
^(2*k), {k, 0, (n - 1)/2}], x]] /; FreeQ[{a, b, e, f}, x] && NeQ[a^2 + b^2, 
 0] && IntegerQ[(m - 1)/2] && IGtQ[n, 0]
 

rule 4147
Int[sin[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]^2)^ 
(p_.), x_Symbol] :> With[{ff = FreeFactors[Sec[e + f*x], x]}, Simp[1/(f*ff^ 
m)   Subst[Int[(-1 + ff^2*x^2)^((m - 1)/2)*((a - b + b*ff^2*x^2)^p/x^(m + 1 
)), x], x, Sec[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f, p}, x] && IntegerQ[( 
m - 1)/2]
 

rule 4159
Int[sec[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]^(n_ 
))^(p_.), x_Symbol] :> With[{ff = FreeFactors[Sin[e + f*x], x]}, Simp[ff/f 
  Subst[Int[ExpandToSum[b*(ff*x)^n + a*(1 - ff^2*x^2)^(n/2), x]^p/(1 - ff^2 
*x^2)^((m + n*p + 1)/2), x], x, Sin[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f} 
, x] && IntegerQ[(m - 1)/2] && IntegerQ[n/2] && IntegerQ[p]
 
Maple [A] (verified)

Time = 2.68 (sec) , antiderivative size = 96, normalized size of antiderivative = 1.32

method result size
derivativedivides \(\frac {b^{3} \left (\frac {\sin \left (d x +c \right )^{4}}{\cos \left (d x +c \right )}+\left (2+\sin \left (d x +c \right )^{2}\right ) \cos \left (d x +c \right )\right )+3 a \,b^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )-3 a^{2} b \cos \left (d x +c \right )+a^{3} \sin \left (d x +c \right )}{d}\) \(96\)
default \(\frac {b^{3} \left (\frac {\sin \left (d x +c \right )^{4}}{\cos \left (d x +c \right )}+\left (2+\sin \left (d x +c \right )^{2}\right ) \cos \left (d x +c \right )\right )+3 a \,b^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )-3 a^{2} b \cos \left (d x +c \right )+a^{3} \sin \left (d x +c \right )}{d}\) \(96\)
risch \(-\frac {3 \,{\mathrm e}^{i \left (d x +c \right )} a^{2} b}{2 d}+\frac {{\mathrm e}^{i \left (d x +c \right )} b^{3}}{2 d}-\frac {i {\mathrm e}^{i \left (d x +c \right )} a^{3}}{2 d}+\frac {3 i {\mathrm e}^{i \left (d x +c \right )} a \,b^{2}}{2 d}-\frac {3 \,{\mathrm e}^{-i \left (d x +c \right )} a^{2} b}{2 d}+\frac {{\mathrm e}^{-i \left (d x +c \right )} b^{3}}{2 d}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} a^{3}}{2 d}-\frac {3 i {\mathrm e}^{-i \left (d x +c \right )} a \,b^{2}}{2 d}+\frac {2 b^{3} {\mathrm e}^{i \left (d x +c \right )}}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}+\frac {3 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) b^{2}}{d}-\frac {3 a \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) b^{2}}{d}\) \(220\)

Input:

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

Output:

1/d*(b^3*(sin(d*x+c)^4/cos(d*x+c)+(2+sin(d*x+c)^2)*cos(d*x+c))+3*a*b^2*(-s 
in(d*x+c)+ln(sec(d*x+c)+tan(d*x+c)))-3*a^2*b*cos(d*x+c)+a^3*sin(d*x+c))
 

Fricas [A] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 109, normalized size of antiderivative = 1.49 \[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {3 \, a b^{2} \cos \left (d x + c\right ) \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, a b^{2} \cos \left (d x + c\right ) \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, b^{3} - 2 \, {\left (3 \, a^{2} b - b^{3}\right )} \cos \left (d x + c\right )^{2} + 2 \, {\left (a^{3} - 3 \, a b^{2}\right )} \cos \left (d x + c\right ) \sin \left (d x + c\right )}{2 \, d \cos \left (d x + c\right )} \] Input:

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

Output:

1/2*(3*a*b^2*cos(d*x + c)*log(sin(d*x + c) + 1) - 3*a*b^2*cos(d*x + c)*log 
(-sin(d*x + c) + 1) + 2*b^3 - 2*(3*a^2*b - b^3)*cos(d*x + c)^2 + 2*(a^3 - 
3*a*b^2)*cos(d*x + c)*sin(d*x + c))/(d*cos(d*x + c))
 

Sympy [F]

\[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{3} \cos {\left (c + d x \right )}\, dx \] Input:

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

Output:

Integral((a + b*tan(c + d*x))**3*cos(c + d*x), x)
 

Maxima [A] (verification not implemented)

Time = 0.06 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.15 \[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {2 \, b^{3} {\left (\frac {1}{\cos \left (d x + c\right )} + \cos \left (d x + c\right )\right )} + 3 \, a b^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right ) - 2 \, \sin \left (d x + c\right )\right )} - 6 \, a^{2} b \cos \left (d x + c\right ) + 2 \, a^{3} \sin \left (d x + c\right )}{2 \, d} \] Input:

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

Output:

1/2*(2*b^3*(1/cos(d*x + c) + cos(d*x + c)) + 3*a*b^2*(log(sin(d*x + c) + 1 
) - log(sin(d*x + c) - 1) - 2*sin(d*x + c)) - 6*a^2*b*cos(d*x + c) + 2*a^3 
*sin(d*x + c))/d
 

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 4309 vs. \(2 (73) = 146\).

Time = 2.05 (sec) , antiderivative size = 4309, normalized size of antiderivative = 59.03 \[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\text {Too large to display} \] Input:

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

Output:

-1/4*(3*pi*a^2*b*sgn(tan(1/2*d*x)^2*tan(1/2*c)^2 - tan(1/2*d*x)^2 - 4*tan( 
1/2*d*x)*tan(1/2*c) - tan(1/2*c)^2 + 1)*tan(1/2*d*x)^4*tan(1/2*c)^4 - 3*pi 
*a^2*b*tan(1/2*d*x)^4*tan(1/2*c)^4 - 6*a^2*b*arctan((tan(1/2*d*x)*tan(1/2* 
c) + tan(1/2*d*x) + tan(1/2*c) - 1)/(tan(1/2*d*x)*tan(1/2*c) - tan(1/2*d*x 
) - tan(1/2*c) - 1))*tan(1/2*d*x)^4*tan(1/2*c)^4 - 6*a^2*b*arctan((tan(1/2 
*d*x)*tan(1/2*c) - tan(1/2*d*x) - tan(1/2*c) - 1)/(tan(1/2*d*x)*tan(1/2*c) 
 + tan(1/2*d*x) + tan(1/2*c) - 1))*tan(1/2*d*x)^4*tan(1/2*c)^4 + 6*a*b^2*l 
og(2*(tan(1/2*d*x)^2*tan(1/2*c)^2 + 2*tan(1/2*d*x)^2*tan(1/2*c) + 2*tan(1/ 
2*d*x)*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 - 2*tan(1/2*d*x) - 2*t 
an(1/2*c) + 1)/(tan(1/2*d*x)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^ 
2 + 1))*tan(1/2*d*x)^4*tan(1/2*c)^4 - 6*a*b^2*log(2*(tan(1/2*d*x)^2*tan(1/ 
2*c)^2 - 2*tan(1/2*d*x)^2*tan(1/2*c) - 2*tan(1/2*d*x)*tan(1/2*c)^2 + tan(1 
/2*d*x)^2 + tan(1/2*c)^2 + 2*tan(1/2*d*x) + 2*tan(1/2*c) + 1)/(tan(1/2*d*x 
)^2*tan(1/2*c)^2 + tan(1/2*d*x)^2 + tan(1/2*c)^2 + 1))*tan(1/2*d*x)^4*tan( 
1/2*c)^4 - 12*pi*a^2*b*sgn(tan(1/2*d*x)^2*tan(1/2*c)^2 - tan(1/2*d*x)^2 - 
4*tan(1/2*d*x)*tan(1/2*c) - tan(1/2*c)^2 + 1)*tan(1/2*d*x)^3*tan(1/2*c)^3 
+ 12*a^2*b*tan(1/2*d*x)^4*tan(1/2*c)^4 - 8*b^3*tan(1/2*d*x)^4*tan(1/2*c)^4 
 + 12*pi*a^2*b*tan(1/2*d*x)^3*tan(1/2*c)^3 + 24*a^2*b*arctan((tan(1/2*d*x) 
*tan(1/2*c) + tan(1/2*d*x) + tan(1/2*c) - 1)/(tan(1/2*d*x)*tan(1/2*c) - ta 
n(1/2*d*x) - tan(1/2*c) - 1))*tan(1/2*d*x)^3*tan(1/2*c)^3 + 24*a^2*b*ar...
 

Mupad [B] (verification not implemented)

Time = 1.31 (sec) , antiderivative size = 116, normalized size of antiderivative = 1.59 \[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {6\,a\,b^2\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{d}-\frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\,\left (6\,a\,b^2-2\,a^3\right )-6\,a^2\,b-\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (6\,a\,b^2-2\,a^3\right )+4\,b^3+6\,a^2\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-1\right )} \] Input:

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

Output:

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

Reduce [B] (verification not implemented)

Time = 0.15 (sec) , antiderivative size = 156, normalized size of antiderivative = 2.14 \[ \int \cos (c+d x) (a+b \tan (c+d x))^3 \, dx=\frac {-3 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right ) a \,b^{2}+3 \cos \left (d x +c \right ) \mathrm {log}\left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right ) a \,b^{2}+\cos \left (d x +c \right ) \sin \left (d x +c \right ) a^{3}-3 \cos \left (d x +c \right ) \sin \left (d x +c \right ) a \,b^{2}+3 \cos \left (d x +c \right ) a^{2} b -2 \cos \left (d x +c \right ) b^{3}+3 \sin \left (d x +c \right )^{2} a^{2} b -\sin \left (d x +c \right )^{2} b^{3}-3 a^{2} b +2 b^{3}}{\cos \left (d x +c \right ) d} \] Input:

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

Output:

( - 3*cos(c + d*x)*log(tan((c + d*x)/2) - 1)*a*b**2 + 3*cos(c + d*x)*log(t 
an((c + d*x)/2) + 1)*a*b**2 + cos(c + d*x)*sin(c + d*x)*a**3 - 3*cos(c + d 
*x)*sin(c + d*x)*a*b**2 + 3*cos(c + d*x)*a**2*b - 2*cos(c + d*x)*b**3 + 3* 
sin(c + d*x)**2*a**2*b - sin(c + d*x)**2*b**3 - 3*a**2*b + 2*b**3)/(cos(c 
+ d*x)*d)