3.343 \(\int (\sin (x)+\tan (x))^2 \, dx\)

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

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.0625847, antiderivative size = 25, normalized size of antiderivative = 1., number of steps used = 9, number of rules used = 7, integrand size = 7, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 1., Rules used = {4397, 2709, 2637, 2635, 8, 3770, 3767} \[ -\frac{x}{2}-2 \sin (x)+\tan (x)+2 \tanh ^{-1}(\sin (x))-\frac{1}{2} \sin (x) \cos (x) \]

Antiderivative was successfully verified.

[In]

Int[(Sin[x] + Tan[x])^2,x]

[Out]

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

Rule 4397

Int[u_, x_Symbol] :> Int[TrigSimplify[u], x] /; TrigSimplifyQ[u]

Rule 2709

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_)*tan[(e_.) + (f_.)*(x_)]^(p_), x_Symbol] :> Dist[a^p, Int[Expan
dIntegrand[(Sin[e + f*x]^p*(a + b*Sin[e + f*x])^(m - p/2))/(a - b*Sin[e + f*x])^(p/2), x], x], x] /; FreeQ[{a,
 b, e, f}, x] && EqQ[a^2 - b^2, 0] && IntegersQ[m, p/2] && (LtQ[p, 0] || GtQ[m - p/2, 0])

Rule 2637

Int[sin[Pi/2 + (c_.) + (d_.)*(x_)], x_Symbol] :> Simp[Sin[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 2635

Int[((b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> -Simp[(b*Cos[c + d*x]*(b*Sin[c + d*x])^(n - 1))/(d*n),
x] + Dist[(b^2*(n - 1))/n, Int[(b*Sin[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1] && Integer
Q[2*n]

Rule 8

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

Rule 3770

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> -Simp[ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rule 3767

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> -Dist[d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rubi steps

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

Mathematica [B]  time = 0.0956259, size = 60, normalized size = 2.4 \[ -\frac{x}{2}-2 \sin (x)+\frac{7 \tan (x)}{8}-\frac{1}{8} \sin (3 x) \sec (x)-2 \log \left (\cos \left (\frac{x}{2}\right )-\sin \left (\frac{x}{2}\right )\right )+2 \log \left (\sin \left (\frac{x}{2}\right )+\cos \left (\frac{x}{2}\right )\right ) \]

Antiderivative was successfully verified.

[In]

Integrate[(Sin[x] + Tan[x])^2,x]

[Out]

-x/2 - 2*Log[Cos[x/2] - Sin[x/2]] + 2*Log[Cos[x/2] + Sin[x/2]] - 2*Sin[x] - (Sec[x]*Sin[3*x])/8 + (7*Tan[x])/8

________________________________________________________________________________________

Maple [A]  time = 0.016, size = 25, normalized size = 1. \begin{align*} -{\frac{\cos \left ( x \right ) \sin \left ( x \right ) }{2}}-{\frac{x}{2}}-2\,\sin \left ( x \right ) +2\,\ln \left ( \sec \left ( x \right ) +\tan \left ( x \right ) \right ) +\tan \left ( x \right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((sin(x)+tan(x))^2,x)

[Out]

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

________________________________________________________________________________________

Maxima [A]  time = 1.47788, size = 38, normalized size = 1.52 \begin{align*} -\frac{1}{2} \, x + \log \left (\sin \left (x\right ) + 1\right ) - \log \left (\sin \left (x\right ) - 1\right ) - \frac{1}{4} \, \sin \left (2 \, x\right ) - 2 \, \sin \left (x\right ) + \tan \left (x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Fricas [B]  time = 2.11352, size = 154, normalized size = 6.16 \begin{align*} -\frac{x \cos \left (x\right ) - 2 \, \cos \left (x\right ) \log \left (\sin \left (x\right ) + 1\right ) + 2 \, \cos \left (x\right ) \log \left (-\sin \left (x\right ) + 1\right ) +{\left (\cos \left (x\right )^{2} + 4 \, \cos \left (x\right ) - 2\right )} \sin \left (x\right )}{2 \, \cos \left (x\right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [A]  time = 1.84119, size = 31, normalized size = 1.24 \begin{align*} - \frac{x}{2} - \log{\left (\sin{\left (x \right )} - 1 \right )} + \log{\left (\sin{\left (x \right )} + 1 \right )} - 2 \sin{\left (x \right )} - \frac{\sin{\left (2 x \right )}}{4} + \tan{\left (x \right )} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((sin(x)+tan(x))**2,x)

[Out]

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

________________________________________________________________________________________

Giac [B]  time = 1.24517, size = 239, normalized size = 9.56 \begin{align*} \frac{1}{2} \, x - \frac{x \tan \left (\frac{1}{2} \, x\right )^{2} - \log \left (\frac{2 \,{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 2 \, \tan \left (\frac{1}{2} \, x\right ) + 1\right )}}{\tan \left (\frac{1}{2} \, x\right )^{2} + 1}\right ) \tan \left (\frac{1}{2} \, x\right )^{2} + \log \left (\frac{2 \,{\left (\tan \left (\frac{1}{2} \, x\right )^{2} - 2 \, \tan \left (\frac{1}{2} \, x\right ) + 1\right )}}{\tan \left (\frac{1}{2} \, x\right )^{2} + 1}\right ) \tan \left (\frac{1}{2} \, x\right )^{2} - \tan \left (\frac{1}{2} \, x\right )^{2} \tan \left (x\right ) + x - \log \left (\frac{2 \,{\left (\tan \left (\frac{1}{2} \, x\right )^{2} + 2 \, \tan \left (\frac{1}{2} \, x\right ) + 1\right )}}{\tan \left (\frac{1}{2} \, x\right )^{2} + 1}\right ) + \log \left (\frac{2 \,{\left (\tan \left (\frac{1}{2} \, x\right )^{2} - 2 \, \tan \left (\frac{1}{2} \, x\right ) + 1\right )}}{\tan \left (\frac{1}{2} \, x\right )^{2} + 1}\right ) + 4 \, \tan \left (\frac{1}{2} \, x\right ) - \tan \left (x\right )}{\tan \left (\frac{1}{2} \, x\right )^{2} + 1} - \frac{1}{4} \, \sin \left (2 \, x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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