\(\int \frac {1}{(a+b \tan (c+d x))^2} \, dx\) [473]

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 = 12, antiderivative size = 82 \[ \int \frac {1}{(a+b \tan (c+d x))^2} \, dx=\frac {\left (a^2-b^2\right ) x}{\left (a^2+b^2\right )^2}+\frac {2 a b \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac {b}{\left (a^2+b^2\right ) d (a+b \tan (c+d x))} \] Output:

(a^2-b^2)*x/(a^2+b^2)^2+2*a*b*ln(a*cos(d*x+c)+b*sin(d*x+c))/(a^2+b^2)^2/d- 
b/(a^2+b^2)/d/(a+b*tan(d*x+c))
 

Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 0.86 (sec) , antiderivative size = 106, normalized size of antiderivative = 1.29 \[ \int \frac {1}{(a+b \tan (c+d x))^2} \, dx=\frac {-\frac {i \log (i-\tan (c+d x))}{(a+i b)^2}+\frac {i \log (i+\tan (c+d x))}{(a-i b)^2}+\frac {2 b \left (2 a \log (a+b \tan (c+d x))-\frac {a^2+b^2}{a+b \tan (c+d x)}\right )}{\left (a^2+b^2\right )^2}}{2 d} \] Input:

Integrate[(a + b*Tan[c + d*x])^(-2),x]
 

Output:

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

Rubi [A] (verified)

Time = 0.48 (sec) , antiderivative size = 93, normalized size of antiderivative = 1.13, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.500, Rules used = {3042, 3964, 3042, 4014, 3042, 4013}

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 3964

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4014

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

\(\Big \downarrow \) 3042

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

\(\Big \downarrow \) 4013

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

Input:

Int[(a + b*Tan[c + d*x])^(-2),x]
 

Output:

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

Defintions of rubi rules used

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

rule 3964
Int[((a_) + (b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((a + 
b*Tan[c + d*x])^(n + 1)/(d*(n + 1)*(a^2 + b^2))), x] + Simp[1/(a^2 + b^2) 
 Int[(a - b*Tan[c + d*x])*(a + b*Tan[c + d*x])^(n + 1), x], x] /; FreeQ[{a, 
 b, c, d}, x] && NeQ[a^2 + b^2, 0] && LtQ[n, -1]
 

rule 4013
Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)* 
(x_)]), x_Symbol] :> Simp[(c/(b*f))*Log[RemoveContent[a*Cos[e + f*x] + b*Si 
n[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] && EqQ[a*c + b*d, 0]
 

rule 4014
Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[(a*c + b*d)*(x/(a^2 + b^2)), x] + Simp[(b*c - a 
*d)/(a^2 + b^2)   Int[(b - a*Tan[e + f*x])/(a + b*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] && N 
eQ[a*c + b*d, 0]
 
Maple [A] (verified)

Time = 0.46 (sec) , antiderivative size = 97, normalized size of antiderivative = 1.18

method result size
derivativedivides \(\frac {\frac {-a b \ln \left (1+\tan \left (d x +c \right )^{2}\right )+\left (a^{2}-b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {b}{\left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )}+\frac {2 a b \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{d}\) \(97\)
default \(\frac {\frac {-a b \ln \left (1+\tan \left (d x +c \right )^{2}\right )+\left (a^{2}-b^{2}\right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {b}{\left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )}+\frac {2 a b \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{d}\) \(97\)
norman \(\frac {\frac {\left (a^{2}-b^{2}\right ) a x}{a^{4}+2 b^{2} a^{2}+b^{4}}+\frac {b \left (a^{2}-b^{2}\right ) x \tan \left (d x +c \right )}{a^{4}+2 b^{2} a^{2}+b^{4}}+\frac {b^{2} \tan \left (d x +c \right )}{a \left (a^{2}+b^{2}\right ) d}}{a +b \tan \left (d x +c \right )}-\frac {a b \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{d \left (a^{4}+2 b^{2} a^{2}+b^{4}\right )}+\frac {2 a b \ln \left (a +b \tan \left (d x +c \right )\right )}{d \left (a^{4}+2 b^{2} a^{2}+b^{4}\right )}\) \(175\)
parallelrisch \(-\frac {-\tan \left (d x +c \right ) a^{3} b d x +x \tan \left (d x +c \right ) a \,b^{3} d +\ln \left (1+\tan \left (d x +c \right )^{2}\right ) \tan \left (d x +c \right ) a^{2} b^{2}-2 \ln \left (a +b \tan \left (d x +c \right )\right ) \tan \left (d x +c \right ) a^{2} b^{2}-a^{4} x d +a^{2} b^{2} d x +\ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{3} b -2 \ln \left (a +b \tan \left (d x +c \right )\right ) a^{3} b -b^{2} a^{2} \tan \left (d x +c \right )-b^{4} \tan \left (d x +c \right )}{\left (a +b \tan \left (d x +c \right )\right ) d a \left (a^{2}+b^{2}\right )^{2}}\) \(181\)
risch \(-\frac {x}{2 i a b -a^{2}+b^{2}}-\frac {4 i a b x}{a^{4}+2 b^{2} a^{2}+b^{4}}-\frac {4 i a b c}{d \left (a^{4}+2 b^{2} a^{2}+b^{4}\right )}-\frac {2 i b^{2}}{\left (-i a +b \right ) d \left (i a +b \right )^{2} \left (b \,{\mathrm e}^{2 i \left (d x +c \right )}+i a \,{\mathrm e}^{2 i \left (d x +c \right )}-b +i a \right )}+\frac {2 a b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right )}{d \left (a^{4}+2 b^{2} a^{2}+b^{4}\right )}\) \(182\)

Input:

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

Output:

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

Fricas [A] (verification not implemented)

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

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

Output:

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

Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.71 (sec) , antiderivative size = 1260, normalized size of antiderivative = 15.37 \[ \int \frac {1}{(a+b \tan (c+d x))^2} \, dx=\text {Too large to display} \] Input:

integrate(1/(a+b*tan(d*x+c))**2,x)
 

Output:

Piecewise((zoo*x/tan(c)**2, Eq(a, 0) & Eq(b, 0) & Eq(d, 0)), (x/a**2, Eq(b 
, 0)), (-d*x*tan(c + d*x)**2/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c 
+ d*x) - 4*b**2*d) + 2*I*d*x*tan(c + d*x)/(4*b**2*d*tan(c + d*x)**2 - 8*I* 
b**2*d*tan(c + d*x) - 4*b**2*d) + d*x/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2 
*d*tan(c + d*x) - 4*b**2*d) - tan(c + d*x)/(4*b**2*d*tan(c + d*x)**2 - 8*I 
*b**2*d*tan(c + d*x) - 4*b**2*d) + 2*I/(4*b**2*d*tan(c + d*x)**2 - 8*I*b** 
2*d*tan(c + d*x) - 4*b**2*d), Eq(a, -I*b)), (-d*x*tan(c + d*x)**2/(4*b**2* 
d*tan(c + d*x)**2 + 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - 2*I*d*x*tan(c + 
d*x)/(4*b**2*d*tan(c + d*x)**2 + 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) + d*x 
/(4*b**2*d*tan(c + d*x)**2 + 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - tan(c + 
 d*x)/(4*b**2*d*tan(c + d*x)**2 + 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - 2* 
I/(4*b**2*d*tan(c + d*x)**2 + 8*I*b**2*d*tan(c + d*x) - 4*b**2*d), Eq(a, I 
*b)), (x/(a + b*tan(c))**2, Eq(d, 0)), (a**3*d*x/(a**5*d + a**4*b*d*tan(c 
+ d*x) + 2*a**3*b**2*d + 2*a**2*b**3*d*tan(c + d*x) + a*b**4*d + b**5*d*ta 
n(c + d*x)) + a**2*b*d*x*tan(c + d*x)/(a**5*d + a**4*b*d*tan(c + d*x) + 2* 
a**3*b**2*d + 2*a**2*b**3*d*tan(c + d*x) + a*b**4*d + b**5*d*tan(c + d*x)) 
 + 2*a**2*b*log(a/b + tan(c + d*x))/(a**5*d + a**4*b*d*tan(c + d*x) + 2*a* 
*3*b**2*d + 2*a**2*b**3*d*tan(c + d*x) + a*b**4*d + b**5*d*tan(c + d*x)) - 
 a**2*b*log(tan(c + d*x)**2 + 1)/(a**5*d + a**4*b*d*tan(c + d*x) + 2*a**3* 
b**2*d + 2*a**2*b**3*d*tan(c + d*x) + a*b**4*d + b**5*d*tan(c + d*x)) -...
 

Maxima [A] (verification not implemented)

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

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

Output:

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

Giac [A] (verification not implemented)

Time = 0.17 (sec) , antiderivative size = 151, normalized size of antiderivative = 1.84 \[ \int \frac {1}{(a+b \tan (c+d x))^2} \, dx=\frac {2 \, a b^{2} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b d + 2 \, a^{2} b^{3} d + b^{5} d} - \frac {a b \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} d + 2 \, a^{2} b^{2} d + b^{4} d} + \frac {{\left (a^{2} - b^{2}\right )} {\left (d x + c\right )}}{a^{4} d + 2 \, a^{2} b^{2} d + b^{4} d} - \frac {a^{2} b + b^{3}}{{\left (a^{2} + b^{2}\right )}^{2} {\left (b \tan \left (d x + c\right ) + a\right )} d} \] Input:

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

Output:

2*a*b^2*log(abs(b*tan(d*x + c) + a))/(a^4*b*d + 2*a^2*b^3*d + b^5*d) - a*b 
*log(tan(d*x + c)^2 + 1)/(a^4*d + 2*a^2*b^2*d + b^4*d) + (a^2 - b^2)*(d*x 
+ c)/(a^4*d + 2*a^2*b^2*d + b^4*d) - (a^2*b + b^3)/((a^2 + b^2)^2*(b*tan(d 
*x + c) + a)*d)
 

Mupad [B] (verification not implemented)

Time = 1.09 (sec) , antiderivative size = 121, normalized size of antiderivative = 1.48 \[ \int \frac {1}{(a+b \tan (c+d x))^2} \, dx=\frac {2\,a\,b\,\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}{d\,{\left (a^2+b^2\right )}^2}-\frac {b}{d\,\left (a^2+b^2\right )\,\left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )}{2\,d\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,1{}\mathrm {i}}{2\,d\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )} \] Input:

int(1/(a + b*tan(c + d*x))^2,x)
 

Output:

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

Reduce [B] (verification not implemented)

Time = 0.16 (sec) , antiderivative size = 212, normalized size of antiderivative = 2.59 \[ \int \frac {1}{(a+b \tan (c+d x))^2} \, dx=\frac {-\mathrm {log}\left (\tan \left (d x +c \right )^{2}+1\right ) \tan \left (d x +c \right ) a^{2} b^{2}-\mathrm {log}\left (\tan \left (d x +c \right )^{2}+1\right ) a^{3} b +2 \,\mathrm {log}\left (a +\tan \left (d x +c \right ) b \right ) \tan \left (d x +c \right ) a^{2} b^{2}+2 \,\mathrm {log}\left (a +\tan \left (d x +c \right ) b \right ) a^{3} b +\tan \left (d x +c \right ) a^{3} b d x +\tan \left (d x +c \right ) a^{2} b^{2}-\tan \left (d x +c \right ) a \,b^{3} d x +\tan \left (d x +c \right ) b^{4}+a^{4} d x -a^{2} b^{2} d x}{a d \left (\tan \left (d x +c \right ) a^{4} b +2 \tan \left (d x +c \right ) a^{2} b^{3}+\tan \left (d x +c \right ) b^{5}+a^{5}+2 a^{3} b^{2}+a \,b^{4}\right )} \] Input:

int(1/(a+b*tan(d*x+c))^2,x)
 

Output:

( - log(tan(c + d*x)**2 + 1)*tan(c + d*x)*a**2*b**2 - log(tan(c + d*x)**2 
+ 1)*a**3*b + 2*log(tan(c + d*x)*b + a)*tan(c + d*x)*a**2*b**2 + 2*log(tan 
(c + d*x)*b + a)*a**3*b + tan(c + d*x)*a**3*b*d*x + tan(c + d*x)*a**2*b**2 
 - tan(c + d*x)*a*b**3*d*x + tan(c + d*x)*b**4 + a**4*d*x - a**2*b**2*d*x) 
/(a*d*(tan(c + d*x)*a**4*b + 2*tan(c + d*x)*a**2*b**3 + tan(c + d*x)*b**5 
+ a**5 + 2*a**3*b**2 + a*b**4))