3.1.40 \(\int (-\sec (x)+\tan (x))^2 \, dx\) [40]

Optimal. Leaf size=14 \[ -x-\frac {2 \cos (x)}{1+\sin (x)} \]

[Out]

-x-2*cos(x)/(1+sin(x))

________________________________________________________________________________________

Rubi [A]
time = 0.05, antiderivative size = 14, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 4, integrand size = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.444, Rules used = {4476, 2749, 2759, 8} \begin {gather*} -x-\frac {2 \cos (x)}{\sin (x)+1} \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

-x - (2*Cos[x])/(1 + Sin[x])

Rule 8

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

Rule 2749

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Dist[(a/g)^
(2*m), Int[(g*Cos[e + f*x])^(2*m + p)/(a - b*Sin[e + f*x])^m, x], x] /; FreeQ[{a, b, e, f, g}, x] && EqQ[a^2 -
 b^2, 0] && IntegerQ[m] && LtQ[p, -1] && GeQ[2*m + p, 0]

Rule 2759

Int[(cos[(e_.) + (f_.)*(x_)]*(g_.))^(p_)*((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_), x_Symbol] :> Simp[2*g*(g
*Cos[e + f*x])^(p - 1)*((a + b*Sin[e + f*x])^(m + 1)/(b*f*(2*m + p + 1))), x] + Dist[g^2*((p - 1)/(b^2*(2*m +
p + 1))), Int[(g*Cos[e + f*x])^(p - 2)*(a + b*Sin[e + f*x])^(m + 2), x], x] /; FreeQ[{a, b, e, f, g}, x] && Eq
Q[a^2 - b^2, 0] && LeQ[m, -2] && GtQ[p, 1] && NeQ[2*m + p + 1, 0] &&  !ILtQ[m + p + 1, 0] && IntegersQ[2*m, 2*
p]

Rule 4476

Int[(u_.)*((b_.)*sec[(c_.) + (d_.)*(x_)]^(n_.) + (a_.)*tan[(c_.) + (d_.)*(x_)]^(n_.))^(p_), x_Symbol] :> Int[A
ctivateTrig[u]*Sec[c + d*x]^(n*p)*(b + a*Sin[c + d*x]^n)^p, x] /; FreeQ[{a, b, c, d}, x] && IntegersQ[n, p]

Rubi steps

\begin {align*} \int (-\sec (x)+\tan (x))^2 \, dx &=\int \sec ^2(x) (-1+\sin (x))^2 \, dx\\ &=\int \frac {\cos ^2(x)}{(-1-\sin (x))^2} \, dx\\ &=-\frac {2 \cos (x)}{1+\sin (x)}-\int 1 \, dx\\ &=-x-\frac {2 \cos (x)}{1+\sin (x)}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.01, size = 12, normalized size = 0.86 \begin {gather*} -x-2 \sec (x)+2 \tan (x) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

-x - 2*Sec[x] + 2*Tan[x]

________________________________________________________________________________________

Maple [A]
time = 0.04, size = 15, normalized size = 1.07

method result size
default \(2 \tan \left (x \right )-\frac {2}{\cos \left (x \right )}-x\) \(15\)
risch \(-x -\frac {4}{{\mathrm e}^{i x}+i}\) \(17\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

2*tan(x)-2/cos(x)-x

________________________________________________________________________________________

Maxima [A]
time = 2.16, size = 14, normalized size = 1.00 \begin {gather*} -x - \frac {2}{\cos \left (x\right )} + 2 \, \tan \left (x\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-x - 2/cos(x) + 2*tan(x)

________________________________________________________________________________________

Fricas [A]
time = 0.61, size = 25, normalized size = 1.79 \begin {gather*} -\frac {{\left (x + 2\right )} \cos \left (x\right ) + {\left (x - 2\right )} \sin \left (x\right ) + x + 2}{\cos \left (x\right ) + \sin \left (x\right ) + 1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-((x + 2)*cos(x) + (x - 2)*sin(x) + x + 2)/(cos(x) + sin(x) + 1)

________________________________________________________________________________________

Sympy [A]
time = 0.64, size = 10, normalized size = 0.71 \begin {gather*} - x + 2 \tan {\left (x \right )} - 2 \sec {\left (x \right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((-sec(x)+tan(x))**2,x)

[Out]

-x + 2*tan(x) - 2*sec(x)

________________________________________________________________________________________

Giac [A]
time = 1.05, size = 14, normalized size = 1.00 \begin {gather*} -x - \frac {4}{\tan \left (\frac {1}{2} \, x\right ) + 1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Mupad [B]
time = 0.27, size = 14, normalized size = 1.00 \begin {gather*} -x-\frac {4}{\mathrm {tan}\left (\frac {x}{2}\right )+1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________