3.910 \(\int \frac{-1+\sec (x)}{1-\tan (x)} \, dx\)

Optimal. Leaf size=37 \[ -\frac{x}{2}+\frac{1}{2} \log (\cos (x)-\sin (x))+\frac{\tanh ^{-1}\left (\frac{\cos (x) (\tan (x)+1)}{\sqrt{2}}\right )}{\sqrt{2}} \]

[Out]

-x/2 + ArcTanh[(Cos[x]*(1 + Tan[x]))/Sqrt[2]]/Sqrt[2] + Log[Cos[x] - Sin[x]]/2

________________________________________________________________________________________

Rubi [A]  time = 0.0895854, antiderivative size = 37, normalized size of antiderivative = 1., number of steps used = 6, number of rules used = 5, integrand size = 13, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.385, Rules used = {4401, 3484, 3530, 3509, 206} \[ -\frac{x}{2}+\frac{1}{2} \log (\cos (x)-\sin (x))+\frac{\tanh ^{-1}\left (\frac{\cos (x) (\tan (x)+1)}{\sqrt{2}}\right )}{\sqrt{2}} \]

Antiderivative was successfully verified.

[In]

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

[Out]

-x/2 + ArcTanh[(Cos[x]*(1 + Tan[x]))/Sqrt[2]]/Sqrt[2] + Log[Cos[x] - Sin[x]]/2

Rule 4401

Int[u_, x_Symbol] :> With[{v = ExpandTrig[u, x]}, Int[v, x] /; SumQ[v]] /;  !InertTrigFreeQ[u]

Rule 3484

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

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), 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 3509

Int[sec[(e_.) + (f_.)*(x_)]/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> -Dist[f^(-1), Subst[Int[1/(a^
2 + b^2 - x^2), x], x, (b - a*Tan[e + f*x])/Sec[e + f*x]], x] /; FreeQ[{a, b, e, f}, x] && NeQ[a^2 + b^2, 0]

Rule 206

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTanh[(Rt[-b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[-b, 2]), x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rubi steps

\begin{align*} \int \frac{-1+\sec (x)}{1-\tan (x)} \, dx &=\int \left (\frac{1}{-1+\tan (x)}-\frac{\sec (x)}{-1+\tan (x)}\right ) \, dx\\ &=\int \frac{1}{-1+\tan (x)} \, dx-\int \frac{\sec (x)}{-1+\tan (x)} \, dx\\ &=-\frac{x}{2}+\frac{1}{2} \int \frac{1+\tan (x)}{-1+\tan (x)} \, dx+\operatorname{Subst}\left (\int \frac{1}{2-x^2} \, dx,x,\cos (x) (1+\tan (x))\right )\\ &=-\frac{x}{2}+\frac{\tanh ^{-1}\left (\frac{\cos (x) (1+\tan (x))}{\sqrt{2}}\right )}{\sqrt{2}}+\frac{1}{2} \log (\cos (x)-\sin (x))\\ \end{align*}

Mathematica [C]  time = 0.0602444, size = 40, normalized size = 1.08 \[ \frac{1}{2} \left (-x+(2-2 i) \sqrt [4]{-1} \tanh ^{-1}\left (\frac{\tan \left (\frac{x}{2}\right )+1}{\sqrt{2}}\right )+\log (\cos (x)-\sin (x))\right ) \]

Antiderivative was successfully verified.

[In]

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

[Out]

(-x + (2 - 2*I)*(-1)^(1/4)*ArcTanh[(1 + Tan[x/2])/Sqrt[2]] + Log[Cos[x] - Sin[x]])/2

________________________________________________________________________________________

Maple [A]  time = 0.045, size = 51, normalized size = 1.4 \begin{align*}{\frac{1}{2}\ln \left ( \left ( \tan \left ({\frac{x}{2}} \right ) \right ) ^{2}+2\,\tan \left ( x/2 \right ) -1 \right ) }+\sqrt{2}{\it Artanh} \left ({\frac{\sqrt{2}}{4} \left ( 2+2\,\tan \left ( x/2 \right ) \right ) } \right ) -{\frac{1}{2}\ln \left ( 1+ \left ( \tan \left ({\frac{x}{2}} \right ) \right ) ^{2} \right ) }-{\frac{x}{2}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((-1+sec(x))/(1-tan(x)),x)

[Out]

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

________________________________________________________________________________________

Maxima [A]  time = 1.45566, size = 80, normalized size = 2.16 \begin{align*} -\frac{1}{2} \, \sqrt{2} \log \left (-\frac{\sqrt{2} - \frac{\sin \left (x\right )}{\cos \left (x\right ) + 1} - 1}{\sqrt{2} + \frac{\sin \left (x\right )}{\cos \left (x\right ) + 1} + 1}\right ) - \frac{1}{2} \, x - \frac{1}{4} \, \log \left (\tan \left (x\right )^{2} + 1\right ) + \frac{1}{2} \, \log \left (\tan \left (x\right ) - 1\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-1/2*sqrt(2)*log(-(sqrt(2) - sin(x)/(cos(x) + 1) - 1)/(sqrt(2) + sin(x)/(cos(x) + 1) + 1)) - 1/2*x - 1/4*log(t
an(x)^2 + 1) + 1/2*log(tan(x) - 1)

________________________________________________________________________________________

Fricas [A]  time = 2.20353, size = 180, normalized size = 4.86 \begin{align*} \frac{1}{4} \, \sqrt{2} \log \left (\frac{2 \,{\left (\sqrt{2} + \cos \left (x\right )\right )} \sin \left (x\right ) + 2 \, \sqrt{2} \cos \left (x\right ) + 3}{2 \, \cos \left (x\right ) \sin \left (x\right ) - 1}\right ) - \frac{1}{2} \, x + \frac{1}{4} \, \log \left (-2 \, \cos \left (x\right ) \sin \left (x\right ) + 1\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

1/4*sqrt(2)*log((2*(sqrt(2) + cos(x))*sin(x) + 2*sqrt(2)*cos(x) + 3)/(2*cos(x)*sin(x) - 1)) - 1/2*x + 1/4*log(
-2*cos(x)*sin(x) + 1)

________________________________________________________________________________________

Sympy [F]  time = 0., size = 0, normalized size = 0. \begin{align*} - \int \frac{\sec{\left (x \right )}}{\tan{\left (x \right )} - 1}\, dx - \int - \frac{1}{\tan{\left (x \right )} - 1}\, dx \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-1+sec(x))/(1-tan(x)),x)

[Out]

-Integral(sec(x)/(tan(x) - 1), x) - Integral(-1/(tan(x) - 1), x)

________________________________________________________________________________________

Giac [B]  time = 1.16572, size = 95, normalized size = 2.57 \begin{align*} -\frac{1}{2} \, \sqrt{2} \log \left (\frac{{\left | -2 \, \sqrt{2} + 2 \, \tan \left (\frac{1}{2} \, x\right ) + 2 \right |}}{{\left | 2 \, \sqrt{2} + 2 \, \tan \left (\frac{1}{2} \, x\right ) + 2 \right |}}\right ) - \frac{1}{2} \, x - \frac{1}{2} \, \log \left (\tan \left (\frac{1}{2} \, x\right )^{2} + 1\right ) + \frac{1}{2} \, \log \left ({\left | \tan \left (\frac{1}{2} \, x\right )^{2} + 2 \, \tan \left (\frac{1}{2} \, x\right ) - 1 \right |}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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