\(\int \frac {1}{(\sec (x)+\tan (x))^4} \, dx\) [281]

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

Optimal result

Integrand size = 7, antiderivative size = 26 \[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=x-\frac {2 \cos ^3(x)}{3 (1+\sin (x))^3}+\frac {2 \cos (x)}{1+\sin (x)} \]

[Out]

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

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 26, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.429, Rules used = {4476, 2759, 8} \[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=x-\frac {2 \cos ^3(x)}{3 (\sin (x)+1)^3}+\frac {2 \cos (x)}{\sin (x)+1} \]

[In]

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

[Out]

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

Rule 8

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

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*} \text {integral}& = \int \frac {\cos ^4(x)}{(1+\sin (x))^4} \, dx \\ & = -\frac {2 \cos ^3(x)}{3 (1+\sin (x))^3}-\int \frac {\cos ^2(x)}{(1+\sin (x))^2} \, dx \\ & = -\frac {2 \cos ^3(x)}{3 (1+\sin (x))^3}+\frac {2 \cos (x)}{1+\sin (x)}+\int 1 \, dx \\ & = x-\frac {2 \cos ^3(x)}{3 (1+\sin (x))^3}+\frac {2 \cos (x)}{1+\sin (x)} \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(62\) vs. \(2(26)=52\).

Time = 0.07 (sec) , antiderivative size = 62, normalized size of antiderivative = 2.38 \[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=\frac {3 (-8+3 x) \cos \left (\frac {x}{2}\right )+(16-3 x) \cos \left (\frac {3 x}{2}\right )+6 (-4+2 x+x \cos (x)) \sin \left (\frac {x}{2}\right )}{6 \left (\cos \left (\frac {x}{2}\right )+\sin \left (\frac {x}{2}\right )\right )^3} \]

[In]

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

[Out]

(3*(-8 + 3*x)*Cos[x/2] + (16 - 3*x)*Cos[(3*x)/2] + 6*(-4 + 2*x + x*Cos[x])*Sin[x/2])/(6*(Cos[x/2] + Sin[x/2])^
3)

Maple [A] (verified)

Time = 2.80 (sec) , antiderivative size = 29, normalized size of antiderivative = 1.12

method result size
default \(2 \arctan \left (\tan \left (\frac {x}{2}\right )\right )-\frac {16}{3 \left (\tan \left (\frac {x}{2}\right )+1\right )^{3}}+\frac {8}{\left (\tan \left (\frac {x}{2}\right )+1\right )^{2}}\) \(29\)
risch \(x +\frac {-\frac {16}{3}+8 i {\mathrm e}^{i x}+8 \,{\mathrm e}^{2 i x}}{\left (i+{\mathrm e}^{i x}\right )^{3}}\) \(32\)

[In]

int(1/(sec(x)+tan(x))^4,x,method=_RETURNVERBOSE)

[Out]

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

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 63 vs. \(2 (24) = 48\).

Time = 0.25 (sec) , antiderivative size = 63, normalized size of antiderivative = 2.42 \[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=\frac {{\left (3 \, x - 8\right )} \cos \left (x\right )^{2} - {\left (3 \, x + 4\right )} \cos \left (x\right ) - {\left ({\left (3 \, x + 8\right )} \cos \left (x\right ) + 6 \, x + 4\right )} \sin \left (x\right ) - 6 \, x + 4}{3 \, {\left (\cos \left (x\right )^{2} - {\left (\cos \left (x\right ) + 2\right )} \sin \left (x\right ) - \cos \left (x\right ) - 2\right )}} \]

[In]

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

[Out]

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

Sympy [F]

\[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=\int \frac {1}{\left (\tan {\left (x \right )} + \sec {\left (x \right )}\right )^{4}}\, dx \]

[In]

integrate(1/(sec(x)+tan(x))**4,x)

[Out]

Integral((tan(x) + sec(x))**(-4), x)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 64 vs. \(2 (24) = 48\).

Time = 0.31 (sec) , antiderivative size = 64, normalized size of antiderivative = 2.46 \[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=\frac {8 \, {\left (\frac {3 \, \sin \left (x\right )}{\cos \left (x\right ) + 1} + 1\right )}}{3 \, {\left (\frac {3 \, \sin \left (x\right )}{\cos \left (x\right ) + 1} + \frac {3 \, \sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}} + \frac {\sin \left (x\right )^{3}}{{\left (\cos \left (x\right ) + 1\right )}^{3}} + 1\right )}} + 2 \, \arctan \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1}\right ) \]

[In]

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

[Out]

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

Giac [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 20, normalized size of antiderivative = 0.77 \[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=x + \frac {8 \, {\left (3 \, \tan \left (\frac {1}{2} \, x\right ) + 1\right )}}{3 \, {\left (\tan \left (\frac {1}{2} \, x\right ) + 1\right )}^{3}} \]

[In]

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

[Out]

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

Mupad [B] (verification not implemented)

Time = 31.76 (sec) , antiderivative size = 19, normalized size of antiderivative = 0.73 \[ \int \frac {1}{(\sec (x)+\tan (x))^4} \, dx=x+\frac {8\,\mathrm {tan}\left (\frac {x}{2}\right )+\frac {8}{3}}{{\left (\mathrm {tan}\left (\frac {x}{2}\right )+1\right )}^3} \]

[In]

int(1/(tan(x) + 1/cos(x))^4,x)

[Out]

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