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]
________________________________________________________________________________________
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]
[Out]
Rule 8
Rule 2635
Rule 2637
Rule 2709
Rule 3767
Rule 3770
Rule 4397
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________
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]
[Out]
________________________________________________________________________________________