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]

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

________________________________________________________________________________________

Rubi [A]  time = 0.06, antiderivative size = 25, normalized size of antiderivative = 1.00, number of steps used = 9, number of rules used = 7, integrand size = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 1.000, 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 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, 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 2637

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

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 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]

Rule 3770

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

Rule 4397

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

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.09, size = 60, normalized size = 2.40 \[ -\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]

-1/2*x - 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

________________________________________________________________________________________

fricas [B]  time = 0.97, size = 44, normalized size = 1.76 \[ -\frac {x \cos \relax (x) - 2 \, \cos \relax (x) \log \left (\sin \relax (x) + 1\right ) + 2 \, \cos \relax (x) \log \left (-\sin \relax (x) + 1\right ) + {\left (\cos \relax (x)^{2} + 4 \, \cos \relax (x) - 2\right )} \sin \relax (x)}{2 \, \cos \relax (x)} \]

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)

________________________________________________________________________________________

giac [B]  time = 0.20, size = 177, normalized size = 7.08 \[ \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 \relax (x) + 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 \relax (x)}{\tan \left (\frac {1}{2} \, x\right )^{2} + 1} - \frac {1}{4} \, \sin \left (2 \, x\right ) \]

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)

________________________________________________________________________________________

maple [A]  time = 0.05, size = 25, normalized size = 1.00 \[ -\frac {\cos \relax (x ) \sin \relax (x )}{2}-\frac {x}{2}-2 \sin \relax (x )+2 \ln \left (\sec \relax (x )+\tan \relax (x )\right )+\tan \relax (x ) \]

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 = 0.41, size = 28, normalized size = 1.12 \[ -\frac {1}{2} \, x + \log \left (\sin \relax (x) + 1\right ) - \log \left (\sin \relax (x) - 1\right ) - \frac {1}{4} \, \sin \left (2 \, x\right ) - 2 \, \sin \relax (x) + \tan \relax (x) \]

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)

________________________________________________________________________________________

mupad [B]  time = 2.42, size = 61, normalized size = 2.44 \[ 4\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {x}{2}\right )\right )-\frac {x}{2}+\frac {5\,{\mathrm {tan}\left (\frac {x}{2}\right )}^5+6\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3-3\,\mathrm {tan}\left (\frac {x}{2}\right )}{-{\mathrm {tan}\left (\frac {x}{2}\right )}^6-{\mathrm {tan}\left (\frac {x}{2}\right )}^4+{\mathrm {tan}\left (\frac {x}{2}\right )}^2+1} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

sympy [A]  time = 1.66, size = 31, normalized size = 1.24 \[ - \frac {x}{2} - \log {\left (\sin {\relax (x )} - 1 \right )} + \log {\left (\sin {\relax (x )} + 1 \right )} - 2 \sin {\relax (x )} - \frac {\sin {\left (2 x \right )}}{4} + \tan {\relax (x )} \]

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)

________________________________________________________________________________________