3.324 \(\int (-\cos (x)+\sec (x))^2 \, dx\)

Optimal. Leaf size=22 \[ -\frac {3 x}{2}+\frac {3 \tan (x)}{2}-\frac {1}{2} \sin ^2(x) \tan (x) \]

[Out]

-3/2*x+3/2*tan(x)-1/2*sin(x)^2*tan(x)

________________________________________________________________________________________

Rubi [A]  time = 0.02, antiderivative size = 22, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, integrand size = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.333, Rules used = {288, 321, 203} \[ -\frac {3 x}{2}+\frac {3 \tan (x)}{2}-\frac {1}{2} \sin ^2(x) \tan (x) \]

Antiderivative was successfully verified.

[In]

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

[Out]

(-3*x)/2 + (3*Tan[x])/2 - (Sin[x]^2*Tan[x])/2

Rule 203

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

Rule 288

Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[(c^(n - 1)*(c*x)^(m - n + 1)*(a + b*x^
n)^(p + 1))/(b*n*(p + 1)), x] - Dist[(c^n*(m - n + 1))/(b*n*(p + 1)), Int[(c*x)^(m - n)*(a + b*x^n)^(p + 1), x
], x] /; FreeQ[{a, b, c}, x] && IGtQ[n, 0] && LtQ[p, -1] && GtQ[m + 1, n] &&  !ILtQ[(m + n*(p + 1) + 1)/n, 0]
&& IntBinomialQ[a, b, c, n, m, p, x]

Rule 321

Int[((c_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[(c^(n - 1)*(c*x)^(m - n + 1)*(a + b*x^n
)^(p + 1))/(b*(m + n*p + 1)), x] - Dist[(a*c^n*(m - n + 1))/(b*(m + n*p + 1)), Int[(c*x)^(m - n)*(a + b*x^n)^p
, x], x] /; FreeQ[{a, b, c, p}, x] && IGtQ[n, 0] && GtQ[m, n - 1] && NeQ[m + n*p + 1, 0] && IntBinomialQ[a, b,
 c, n, m, p, x]

Rubi steps

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

________________________________________________________________________________________

Mathematica [A]  time = 0.02, size = 16, normalized size = 0.73 \[ -\frac {3 x}{2}+\frac {1}{4} \sin (2 x)+\tan (x) \]

Antiderivative was successfully verified.

[In]

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

[Out]

(-3*x)/2 + Sin[2*x]/4 + Tan[x]

________________________________________________________________________________________

fricas [A]  time = 0.95, size = 22, normalized size = 1.00 \[ -\frac {3 \, x \cos \relax (x) - {\left (\cos \relax (x)^{2} + 2\right )} \sin \relax (x)}{2 \, \cos \relax (x)} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

giac [A]  time = 0.14, size = 18, normalized size = 0.82 \[ -\frac {3}{2} \, x + \frac {\tan \relax (x)}{2 \, {\left (\tan \relax (x)^{2} + 1\right )}} + \tan \relax (x) \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-3/2*x + 1/2*tan(x)/(tan(x)^2 + 1) + tan(x)

________________________________________________________________________________________

maple [A]  time = 0.05, size = 13, normalized size = 0.59 \[ \tan \relax (x )-\frac {3 x}{2}+\frac {\cos \relax (x ) \sin \relax (x )}{2} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((-cos(x)+sec(x))^2,x)

[Out]

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

________________________________________________________________________________________

maxima [A]  time = 0.31, size = 12, normalized size = 0.55 \[ -\frac {3}{2} \, x + \frac {1}{4} \, \sin \left (2 \, x\right ) + \tan \relax (x) \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

mupad [B]  time = 2.41, size = 49, normalized size = 2.23 \[ -\frac {3\,x}{2}-\frac {3\,{\mathrm {tan}\left (\frac {x}{2}\right )}^5+2\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3+3\,\mathrm {tan}\left (\frac {x}{2}\right )}{\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2-1\right )\,{\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )}^2} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

- (3*x)/2 - (3*tan(x/2) + 2*tan(x/2)^3 + 3*tan(x/2)^5)/((tan(x/2)^2 - 1)*(tan(x/2)^2 + 1)^2)

________________________________________________________________________________________

sympy [A]  time = 1.62, size = 14, normalized size = 0.64 \[ - \frac {3 x}{2} + \frac {\sin {\left (2 x \right )}}{4} + \tan {\relax (x )} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-3*x/2 + sin(2*x)/4 + tan(x)

________________________________________________________________________________________