\(\int \cos (a+b x) \tan ^2(c+b x) \, dx\) [364]

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

Optimal result

Integrand size = 15, antiderivative size = 46 \[ \int \cos (a+b x) \tan ^2(c+b x) \, dx=\frac {\text {arctanh}(\sin (c+b x)) \cos (a-c)}{b}-\frac {\sec (c+b x) \sin (a-c)}{b}-\frac {\sin (a+b x)}{b} \] Output:

arctanh(sin(b*x+c))*cos(a-c)/b-sec(b*x+c)*sin(a-c)/b-sin(b*x+a)/b
 

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.08 (sec) , antiderivative size = 111, normalized size of antiderivative = 2.41 \[ \int \cos (a+b x) \tan ^2(c+b x) \, dx=-\frac {2 i \arctan \left (\frac {(i \cos (c)+\sin (c)) \left (\cos \left (\frac {b x}{2}\right ) \sin (c)+\cos (c) \sin \left (\frac {b x}{2}\right )\right )}{\cos (c) \cos \left (\frac {b x}{2}\right )-i \cos \left (\frac {b x}{2}\right ) \sin (c)}\right ) \cos (a-c)}{b}-\frac {\cos (b x) \sin (a)}{b}-\frac {\sec (c+b x) \sin (a-c)}{b}-\frac {\cos (a) \sin (b x)}{b} \] Input:

Integrate[Cos[a + b*x]*Tan[c + b*x]^2,x]
 

Output:

((-2*I)*ArcTan[((I*Cos[c] + Sin[c])*(Cos[(b*x)/2]*Sin[c] + Cos[c]*Sin[(b*x 
)/2]))/(Cos[c]*Cos[(b*x)/2] - I*Cos[(b*x)/2]*Sin[c])]*Cos[a - c])/b - (Cos 
[b*x]*Sin[a])/b - (Sec[c + b*x]*Sin[a - c])/b - (Cos[a]*Sin[b*x])/b
 

Rubi [A] (verified)

Time = 0.37 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.533, Rules used = {5090, 3042, 3086, 24, 5087, 3042, 3117, 4257}

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

\(\Big \downarrow \) 5090

\(\displaystyle \int \sin (a+b x) \tan (c+b x)dx-\sin (a-c) \int \sec (c+b x) \tan (c+b x)dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \sin (a+b x) \tan (c+b x)dx-\sin (a-c) \int \sec (c+b x) \tan (c+b x)dx\)

\(\Big \downarrow \) 3086

\(\displaystyle \int \sin (a+b x) \tan (c+b x)dx-\frac {\sin (a-c) \int 1d\sec (c+b x)}{b}\)

\(\Big \downarrow \) 24

\(\displaystyle \int \sin (a+b x) \tan (c+b x)dx-\frac {\sin (a-c) \sec (b x+c)}{b}\)

\(\Big \downarrow \) 5087

\(\displaystyle \cos (a-c) \int \sec (c+b x)dx-\int \cos (a+b x)dx-\frac {\sin (a-c) \sec (b x+c)}{b}\)

\(\Big \downarrow \) 3042

\(\displaystyle \cos (a-c) \int \csc \left (c+b x+\frac {\pi }{2}\right )dx-\int \sin \left (a+b x+\frac {\pi }{2}\right )dx-\frac {\sin (a-c) \sec (b x+c)}{b}\)

\(\Big \downarrow \) 3117

\(\displaystyle \cos (a-c) \int \csc \left (c+b x+\frac {\pi }{2}\right )dx-\frac {\sin (a-c) \sec (b x+c)}{b}-\frac {\sin (a+b x)}{b}\)

\(\Big \downarrow \) 4257

\(\displaystyle \frac {\cos (a-c) \text {arctanh}(\sin (b x+c))}{b}-\frac {\sin (a-c) \sec (b x+c)}{b}-\frac {\sin (a+b x)}{b}\)

Input:

Int[Cos[a + b*x]*Tan[c + b*x]^2,x]
 

Output:

(ArcTanh[Sin[c + b*x]]*Cos[a - c])/b - (Sec[c + b*x]*Sin[a - c])/b - Sin[a 
 + b*x]/b
 

Defintions of rubi rules used

rule 24
Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3086
Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^( 
n_.), x_Symbol] :> Simp[a/f   Subst[Int[(a*x)^(m - 1)*(-1 + x^2)^((n - 1)/2 
), x], x, Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2 
] &&  !(IntegerQ[m/2] && LtQ[0, m, n + 1])
 

rule 3117
Int[sin[Pi/2 + (c_.) + (d_.)*(x_)], x_Symbol] :> Simp[Sin[c + d*x]/d, x] /; 
 FreeQ[{c, d}, x]
 

rule 4257
Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] 
 /; FreeQ[{c, d}, x]
 

rule 5087
Int[Sin[v_]*Tan[w_]^(n_.), x_Symbol] :> -Int[Cos[v]*Tan[w]^(n - 1), x] + Si 
mp[Cos[v - w]   Int[Sec[w]*Tan[w]^(n - 1), x], x] /; GtQ[n, 0] && FreeQ[v - 
 w, x] && NeQ[w, v]
 

rule 5090
Int[Cos[v_]*Tan[w_]^(n_.), x_Symbol] :> Int[Sin[v]*Tan[w]^(n - 1), x] - Sim 
p[Sin[v - w]   Int[Sec[w]*Tan[w]^(n - 1), x], x] /; GtQ[n, 0] && FreeQ[v - 
w, x] && NeQ[w, v]
 
Maple [C] (verified)

Result contains complex when optimal does not.

Time = 0.22 (sec) , antiderivative size = 149, normalized size of antiderivative = 3.24

method result size
risch \(\frac {i {\mathrm e}^{i \left (b x +a \right )}}{2 b}-\frac {i {\mathrm e}^{-i \left (b x +a \right )}}{2 b}-\frac {i \left (-{\mathrm e}^{i \left (b x +3 a \right )}+{\mathrm e}^{i \left (b x +a +2 c \right )}\right )}{b \left ({\mathrm e}^{2 i \left (b x +a +c \right )}+{\mathrm e}^{2 i a}\right )}-\frac {\ln \left ({\mathrm e}^{i \left (b x +a \right )}-i {\mathrm e}^{i \left (a -c \right )}\right ) \cos \left (a -c \right )}{b}+\frac {\ln \left ({\mathrm e}^{i \left (b x +a \right )}+i {\mathrm e}^{i \left (a -c \right )}\right ) \cos \left (a -c \right )}{b}\) \(149\)

Input:

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

Output:

1/2*I/b*exp(I*(b*x+a))-1/2*I/b*exp(-I*(b*x+a))-I/b/(exp(2*I*(b*x+a+c))+exp 
(2*I*a))*(-exp(I*(b*x+3*a))+exp(I*(b*x+a+2*c)))-ln(exp(I*(b*x+a))-I*exp(I* 
(a-c)))/b*cos(a-c)+ln(exp(I*(b*x+a))+I*exp(I*(a-c)))/b*cos(a-c)
 

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 316 vs. \(2 (46) = 92\).

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

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

Output:

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

Sympy [F]

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

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

Output:

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

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 526 vs. \(2 (46) = 92\).

Time = 0.18 (sec) , antiderivative size = 526, normalized size of antiderivative = 11.43 \[ \int \cos (a+b x) \tan ^2(c+b x) \, dx =\text {Too large to display} \] Input:

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

Output:

1/2*((sin(3*b*x + a + 2*c) + sin(b*x + a))*cos(4*b*x + 2*a + 2*c) - 3*(sin 
(2*b*x + 2*a) - sin(2*b*x + 2*c))*cos(3*b*x + a + 2*c) - (cos(3*b*x + a + 
2*c)^2*cos(-a + c) + 2*cos(3*b*x + a + 2*c)*cos(b*x + a)*cos(-a + c) + cos 
(b*x + a)^2*cos(-a + c) + cos(-a + c)*sin(3*b*x + a + 2*c)^2 + 2*cos(-a + 
c)*sin(3*b*x + a + 2*c)*sin(b*x + a) + cos(-a + c)*sin(b*x + a)^2)*log((co 
s(b*x + 2*c)^2 + cos(c)^2 - 2*cos(c)*sin(b*x + 2*c) + sin(b*x + 2*c)^2 + 2 
*cos(b*x + 2*c)*sin(c) + sin(c)^2)/(cos(b*x + 2*c)^2 + cos(c)^2 + 2*cos(c) 
*sin(b*x + 2*c) + sin(b*x + 2*c)^2 - 2*cos(b*x + 2*c)*sin(c) + sin(c)^2)) 
- (cos(3*b*x + a + 2*c) + cos(b*x + a))*sin(4*b*x + 2*a + 2*c) + (3*cos(2* 
b*x + 2*a) - 3*cos(2*b*x + 2*c) - 1)*sin(3*b*x + a + 2*c) - 3*cos(b*x + a) 
*sin(2*b*x + 2*a) + 3*cos(b*x + a)*sin(2*b*x + 2*c) + 3*cos(2*b*x + 2*a)*s 
in(b*x + a) - 3*cos(2*b*x + 2*c)*sin(b*x + a) - sin(b*x + a))/(b*cos(3*b*x 
 + a + 2*c)^2 + 2*b*cos(3*b*x + a + 2*c)*cos(b*x + a) + b*cos(b*x + a)^2 + 
 b*sin(3*b*x + a + 2*c)^2 + 2*b*sin(3*b*x + a + 2*c)*sin(b*x + a) + b*sin( 
b*x + a)^2)
 

Giac [F]

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

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

Output:

integrate(cos(b*x + a)*tan(b*x + c)^2, x)
 

Mupad [B] (verification not implemented)

Time = 25.11 (sec) , antiderivative size = 285, normalized size of antiderivative = 6.20 \[ \int \cos (a+b x) \tan ^2(c+b x) \, dx=-\frac {{\mathrm {e}}^{-a\,1{}\mathrm {i}-b\,x\,1{}\mathrm {i}}\,1{}\mathrm {i}}{2\,b}+\frac {{\mathrm {e}}^{a\,1{}\mathrm {i}+b\,x\,1{}\mathrm {i}}\,1{}\mathrm {i}}{2\,b}-\frac {{\mathrm {e}}^{a\,1{}\mathrm {i}+b\,x\,1{}\mathrm {i}}\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}-c\,2{}\mathrm {i}}-1\right )}{b\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}-c\,2{}\mathrm {i}}\,1{}\mathrm {i}+{\mathrm {e}}^{a\,2{}\mathrm {i}+b\,x\,2{}\mathrm {i}}\,1{}\mathrm {i}\right )}+\frac {\ln \left (-{\mathrm {e}}^{a\,1{}\mathrm {i}}\,{\mathrm {e}}^{b\,x\,1{}\mathrm {i}}\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}+1\right )-\frac {{\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}+1\right )\,1{}\mathrm {i}}{\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}}}\right )\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}-c\,2{}\mathrm {i}}+1\right )}{2\,b\,\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}-c\,2{}\mathrm {i}}}}-\frac {\ln \left (-{\mathrm {e}}^{a\,1{}\mathrm {i}}\,{\mathrm {e}}^{b\,x\,1{}\mathrm {i}}\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}+1\right )+\frac {{\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}+1\right )\,1{}\mathrm {i}}{\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}}\,{\mathrm {e}}^{-c\,2{}\mathrm {i}}}}\right )\,\left ({\mathrm {e}}^{a\,2{}\mathrm {i}-c\,2{}\mathrm {i}}+1\right )}{2\,b\,\sqrt {{\mathrm {e}}^{a\,2{}\mathrm {i}-c\,2{}\mathrm {i}}}} \] Input:

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

Output:

(exp(a*1i + b*x*1i)*1i)/(2*b) - (exp(- a*1i - b*x*1i)*1i)/(2*b) - (exp(a*1 
i + b*x*1i)*(exp(a*2i - c*2i) - 1))/(b*(exp(a*2i - c*2i)*1i + exp(a*2i + b 
*x*2i)*1i)) + (log(- exp(a*1i)*exp(b*x*1i)*(exp(a*2i)*exp(-c*2i) + 1) - (e 
xp(a*2i)*exp(-c*2i)*(exp(a*2i)*exp(-c*2i) + 1)*1i)/(exp(a*2i)*exp(-c*2i))^ 
(1/2))*(exp(a*2i - c*2i) + 1))/(2*b*exp(a*2i - c*2i)^(1/2)) - (log((exp(a* 
2i)*exp(-c*2i)*(exp(a*2i)*exp(-c*2i) + 1)*1i)/(exp(a*2i)*exp(-c*2i))^(1/2) 
 - exp(a*1i)*exp(b*x*1i)*(exp(a*2i)*exp(-c*2i) + 1))*(exp(a*2i - c*2i) + 1 
))/(2*b*exp(a*2i - c*2i)^(1/2))
 

Reduce [F]

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

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

Output:

( - cos(b*x + c)*int(sin(b*x + c)**2/(sin(b*x + c)**2 - 1),x)*b - cos(b*x 
+ c)*int((cos(a + b*x)*sin(b*x + c)**2)/(sin(b*x + c)**2 - 1),x)*b + 2*cos 
(b*x + c)*a + cos(b*x + c)*b*x - sin(b*x + c))/(cos(b*x + c)*b)