\(\int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx\) [63]

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

Optimal result

Integrand size = 17, antiderivative size = 11 \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=\frac {1}{2} \text {arctanh}(2 \cos (x) \sin (x)) \]

[Out]

1/2*arctanh(2*cos(x)*sin(x))

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 11, normalized size of antiderivative = 1.00, number of steps used = 2, number of rules used = 1, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.059, Rules used = {212} \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=\frac {1}{2} \text {arctanh}(2 \sin (x) \cos (x)) \]

[In]

Int[(1 + Tan[x]^2)/(1 - Tan[x]^2),x]

[Out]

ArcTanh[2*Cos[x]*Sin[x]]/2

Rule 212

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] && (GtQ[a, 0] || LtQ[b, 0])

Rubi steps \begin{align*} \text {integral}& = \text {Subst}\left (\int \frac {1}{1-x^2} \, dx,x,\tan (x)\right ) \\ & = \frac {1}{2} \text {arctanh}(2 \cos (x) \sin (x)) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 9, normalized size of antiderivative = 0.82 \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=\frac {1}{2} \text {arctanh}(\sin (2 x)) \]

[In]

Integrate[(1 + Tan[x]^2)/(1 - Tan[x]^2),x]

[Out]

ArcTanh[Sin[2*x]]/2

Maple [A] (verified)

Time = 0.06 (sec) , antiderivative size = 4, normalized size of antiderivative = 0.36

method result size
derivativedivides \(\operatorname {arctanh}\left (\tan \left (x \right )\right )\) \(4\)
default \(\operatorname {arctanh}\left (\tan \left (x \right )\right )\) \(4\)
norman \(-\frac {\ln \left (\tan \left (x \right )-1\right )}{2}+\frac {\ln \left (\tan \left (x \right )+1\right )}{2}\) \(16\)
parallelrisch \(-\frac {\ln \left (\tan \left (x \right )-1\right )}{2}+\frac {\ln \left (\tan \left (x \right )+1\right )}{2}\) \(16\)
risch \(-\frac {\ln \left ({\mathrm e}^{2 i x}-i\right )}{2}+\frac {\ln \left ({\mathrm e}^{2 i x}+i\right )}{2}\) \(24\)

[In]

int((1+tan(x)^2)/(1-tan(x)^2),x,method=_RETURNVERBOSE)

[Out]

arctanh(tan(x))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 45 vs. \(2 (9) = 18\).

Time = 0.25 (sec) , antiderivative size = 45, normalized size of antiderivative = 4.09 \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=\frac {1}{4} \, \log \left (\frac {\tan \left (x\right )^{2} + 2 \, \tan \left (x\right ) + 1}{\tan \left (x\right )^{2} + 1}\right ) - \frac {1}{4} \, \log \left (\frac {\tan \left (x\right )^{2} - 2 \, \tan \left (x\right ) + 1}{\tan \left (x\right )^{2} + 1}\right ) \]

[In]

integrate((1+tan(x)^2)/(1-tan(x)^2),x, algorithm="fricas")

[Out]

1/4*log((tan(x)^2 + 2*tan(x) + 1)/(tan(x)^2 + 1)) - 1/4*log((tan(x)^2 - 2*tan(x) + 1)/(tan(x)^2 + 1))

Sympy [A] (verification not implemented)

Time = 0.06 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.36 \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=- \frac {\log {\left (\tan {\left (x \right )} - 1 \right )}}{2} + \frac {\log {\left (\tan {\left (x \right )} + 1 \right )}}{2} \]

[In]

integrate((1+tan(x)**2)/(1-tan(x)**2),x)

[Out]

-log(tan(x) - 1)/2 + log(tan(x) + 1)/2

Maxima [A] (verification not implemented)

none

Time = 0.22 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.36 \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=\frac {1}{2} \, \log \left (\tan \left (x\right ) + 1\right ) - \frac {1}{2} \, \log \left (\tan \left (x\right ) - 1\right ) \]

[In]

integrate((1+tan(x)^2)/(1-tan(x)^2),x, algorithm="maxima")

[Out]

1/2*log(tan(x) + 1) - 1/2*log(tan(x) - 1)

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 17, normalized size of antiderivative = 1.55 \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=\frac {1}{2} \, \log \left ({\left | \tan \left (x\right ) + 1 \right |}\right ) - \frac {1}{2} \, \log \left ({\left | \tan \left (x\right ) - 1 \right |}\right ) \]

[In]

integrate((1+tan(x)^2)/(1-tan(x)^2),x, algorithm="giac")

[Out]

1/2*log(abs(tan(x) + 1)) - 1/2*log(abs(tan(x) - 1))

Mupad [B] (verification not implemented)

Time = 0.39 (sec) , antiderivative size = 3, normalized size of antiderivative = 0.27 \[ \int \frac {1+\tan ^2(x)}{1-\tan ^2(x)} \, dx=\mathrm {atanh}\left (\mathrm {tan}\left (x\right )\right ) \]

[In]

int(-(tan(x)^2 + 1)/(tan(x)^2 - 1),x)

[Out]

atanh(tan(x))