Optimal. Leaf size=80 \[ x \tan ^{-1}(2 \tan (x))+\frac {1}{2} i x \log \left (1-3 e^{2 i x}\right )-\frac {1}{2} i x \log \left (1-\frac {1}{3} e^{2 i x}\right )-\frac {1}{4} \text {Li}_2\left (\frac {1}{3} e^{2 i x}\right )+\frac {1}{4} \text {Li}_2\left (3 e^{2 i x}\right ) \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.05, antiderivative size = 80, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 4, integrand size = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.800, Rules used = {5275, 2221,
2317, 2438} \begin {gather*} -\frac {1}{4} \text {PolyLog}\left (2,\frac {1}{3} e^{2 i x}\right )+\frac {1}{4} \text {PolyLog}\left (2,3 e^{2 i x}\right )+x \text {ArcTan}(2 \tan (x))+\frac {1}{2} i x \log \left (1-3 e^{2 i x}\right )-\frac {1}{2} i x \log \left (1-\frac {1}{3} e^{2 i x}\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 2221
Rule 2317
Rule 2438
Rule 5275
Rubi steps
\begin {align*} \int \tan ^{-1}(2 \tan (x)) \, dx &=x \tan ^{-1}(2 \tan (x))-3 \int \frac {e^{2 i x} x}{-1+3 e^{2 i x}} \, dx-\int \frac {e^{2 i x} x}{3-e^{2 i x}} \, dx\\ &=x \tan ^{-1}(2 \tan (x))+\frac {1}{2} i x \log \left (1-3 e^{2 i x}\right )-\frac {1}{2} i x \log \left (1-\frac {1}{3} e^{2 i x}\right )-\frac {1}{2} i \int \log \left (1-3 e^{2 i x}\right ) \, dx+\frac {1}{2} i \int \log \left (1-\frac {1}{3} e^{2 i x}\right ) \, dx\\ &=x \tan ^{-1}(2 \tan (x))+\frac {1}{2} i x \log \left (1-3 e^{2 i x}\right )-\frac {1}{2} i x \log \left (1-\frac {1}{3} e^{2 i x}\right )-\frac {1}{4} \text {Subst}\left (\int \frac {\log (1-3 x)}{x} \, dx,x,e^{2 i x}\right )+\frac {1}{4} \text {Subst}\left (\int \frac {\log \left (1-\frac {x}{3}\right )}{x} \, dx,x,e^{2 i x}\right )\\ &=x \tan ^{-1}(2 \tan (x))+\frac {1}{2} i x \log \left (1-3 e^{2 i x}\right )-\frac {1}{2} i x \log \left (1-\frac {1}{3} e^{2 i x}\right )-\frac {1}{4} \text {Li}_2\left (\frac {1}{3} e^{2 i x}\right )+\frac {1}{4} \text {Li}_2\left (3 e^{2 i x}\right )\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice
the leaf count of optimal. \(262\) vs. \(2(80)=160\).
time = 0.18, size = 262, normalized size = 3.28 \begin {gather*} x \tan ^{-1}(2 \tan (x))-\frac {1}{4} i \left (4 i x \tan ^{-1}\left (\frac {\cot (x)}{2}\right )+2 i \cos ^{-1}\left (\frac {5}{3}\right ) \tan ^{-1}(2 \tan (x))+\left (\cos ^{-1}\left (\frac {5}{3}\right )+2 \tan ^{-1}\left (\frac {\cot (x)}{2}\right )+2 \tan ^{-1}(2 \tan (x))\right ) \log \left (\frac {2 i \sqrt {\frac {2}{3}} e^{-i x}}{\sqrt {-5+3 \cos (2 x)}}\right )+\left (\cos ^{-1}\left (\frac {5}{3}\right )-2 \tan ^{-1}\left (\frac {\cot (x)}{2}\right )-2 \tan ^{-1}(2 \tan (x))\right ) \log \left (\frac {2 i \sqrt {\frac {2}{3}} e^{i x}}{\sqrt {-5+3 \cos (2 x)}}\right )-\left (\cos ^{-1}\left (\frac {5}{3}\right )-2 \tan ^{-1}(2 \tan (x))\right ) \log \left (\frac {4 i-4 \tan (x)}{i+2 \tan (x)}\right )-\left (\cos ^{-1}\left (\frac {5}{3}\right )+2 \tan ^{-1}(2 \tan (x))\right ) \log \left (\frac {4 (i+\tan (x))}{3 i+6 \tan (x)}\right )+i \left (-\text {Li}_2\left (\frac {-3 i+6 \tan (x)}{i+2 \tan (x)}\right )+\text {Li}_2\left (\frac {-i+2 \tan (x)}{3 i+6 \tan (x)}\right )\right )\right ) \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.25, size = 113, normalized size = 1.41
method | result | size |
derivativedivides | \(\arctan \left (2 \tan \left (x \right )\right ) \arctan \left (\tan \left (x \right )\right )+\frac {i \arctan \left (\tan \left (x \right )\right ) \ln \left (1-\frac {3 \left (1+i \tan \left (x \right )\right )^{2}}{1+\tan ^{2}\left (x \right )}\right )}{2}+\frac {\polylog \left (2, \frac {3 \left (1+i \tan \left (x \right )\right )^{2}}{1+\tan ^{2}\left (x \right )}\right )}{4}-\frac {i \arctan \left (\tan \left (x \right )\right ) \ln \left (1-\frac {\left (1+i \tan \left (x \right )\right )^{2}}{3 \left (1+\tan ^{2}\left (x \right )\right )}\right )}{2}-\frac {\polylog \left (2, \frac {\left (1+i \tan \left (x \right )\right )^{2}}{3+3 \left (\tan ^{2}\left (x \right )\right )}\right )}{4}\) | \(113\) |
default | \(\arctan \left (2 \tan \left (x \right )\right ) \arctan \left (\tan \left (x \right )\right )+\frac {i \arctan \left (\tan \left (x \right )\right ) \ln \left (1-\frac {3 \left (1+i \tan \left (x \right )\right )^{2}}{1+\tan ^{2}\left (x \right )}\right )}{2}+\frac {\polylog \left (2, \frac {3 \left (1+i \tan \left (x \right )\right )^{2}}{1+\tan ^{2}\left (x \right )}\right )}{4}-\frac {i \arctan \left (\tan \left (x \right )\right ) \ln \left (1-\frac {\left (1+i \tan \left (x \right )\right )^{2}}{3 \left (1+\tan ^{2}\left (x \right )\right )}\right )}{2}-\frac {\polylog \left (2, \frac {\left (1+i \tan \left (x \right )\right )^{2}}{3+3 \left (\tan ^{2}\left (x \right )\right )}\right )}{4}\) | \(113\) |
risch | \(\frac {x \pi \,\mathrm {csgn}\left (\frac {i}{{\mathrm e}^{2 i x}+1}\right ) \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-\frac {1}{3}\right )}{{\mathrm e}^{2 i x}+1}\right )^{2}}{4}+\frac {x \pi \,\mathrm {csgn}\left (i \left ({\mathrm e}^{2 i x}-\frac {1}{3}\right )\right ) \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-\frac {1}{3}\right )}{{\mathrm e}^{2 i x}+1}\right )^{2}}{4}-\frac {x \pi \,\mathrm {csgn}\left (i \left ({\mathrm e}^{2 i x}-3\right )\right ) \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-3\right )}{{\mathrm e}^{2 i x}+1}\right )^{2}}{4}-\frac {x \pi \,\mathrm {csgn}\left (\frac {i}{{\mathrm e}^{2 i x}+1}\right ) \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-3\right )}{{\mathrm e}^{2 i x}+1}\right )^{2}}{4}+\frac {\dilog \left (1+\sqrt {3}\, {\mathrm e}^{i x}\right )}{2}+\frac {\dilog \left (1-\sqrt {3}\, {\mathrm e}^{i x}\right )}{2}-\frac {\dilog \left (1-\frac {\sqrt {3}\, {\mathrm e}^{i x}}{3}\right )}{2}-\frac {\dilog \left (1+\frac {\sqrt {3}\, {\mathrm e}^{i x}}{3}\right )}{2}-\frac {\pi x}{2}-\frac {x \pi \,\mathrm {csgn}\left (\frac {i}{{\mathrm e}^{2 i x}+1}\right ) \mathrm {csgn}\left (i \left ({\mathrm e}^{2 i x}-\frac {1}{3}\right )\right ) \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-\frac {1}{3}\right )}{{\mathrm e}^{2 i x}+1}\right )}{4}+\frac {x \pi \,\mathrm {csgn}\left (i \left ({\mathrm e}^{2 i x}-3\right )\right ) \mathrm {csgn}\left (\frac {i}{{\mathrm e}^{2 i x}+1}\right ) \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-3\right )}{{\mathrm e}^{2 i x}+1}\right )}{4}+\frac {x \pi \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-3\right )}{{\mathrm e}^{2 i x}+1}\right )^{2}}{2}-\frac {\ln \left ({\mathrm e}^{i x}\right ) \ln \left (1+\frac {\sqrt {3}\, {\mathrm e}^{i x}}{3}\right )}{2}+\frac {\ln \left ({\mathrm e}^{i x}\right ) \ln \left ({\mathrm e}^{2 i x}-3\right )}{2}-\frac {\ln \left ({\mathrm e}^{i x}\right ) \ln \left (1-\frac {\sqrt {3}\, {\mathrm e}^{i x}}{3}\right )}{2}-\frac {i x \ln \left ({\mathrm e}^{2 i x}-\frac {1}{3}\right )}{2}-\frac {i x \ln \left (3\right )}{2}+\frac {i x \ln \left (1+\sqrt {3}\, {\mathrm e}^{i x}\right )}{2}+\frac {i x \ln \left (1-\sqrt {3}\, {\mathrm e}^{i x}\right )}{2}-\frac {x \pi \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-3\right )}{{\mathrm e}^{2 i x}+1}\right )^{3}}{4}-\frac {x \pi \mathrm {csgn}\left (\frac {i \left ({\mathrm e}^{2 i x}-\frac {1}{3}\right )}{{\mathrm e}^{2 i x}+1}\right )^{3}}{4}\) | \(500\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 2.74, size = 84, normalized size = 1.05 \begin {gather*} x \arctan \left (2 \, \tan \left (x\right )\right ) - \frac {1}{8} \, \log \left (4 \, \tan \left (x\right )^{2} + 4\right ) \log \left (4 \, \tan \left (x\right )^{2} + 1\right ) + \frac {1}{8} \, \log \left (4 \, \tan \left (x\right )^{2} + 1\right ) \log \left (\frac {4}{9} \, \tan \left (x\right )^{2} + \frac {4}{9}\right ) - \frac {1}{4} \, {\rm Li}_2\left (2 i \, \tan \left (x\right ) - 1\right ) + \frac {1}{4} \, {\rm Li}_2\left (\frac {2}{3} i \, \tan \left (x\right ) + \frac {1}{3}\right ) + \frac {1}{4} \, {\rm Li}_2\left (-\frac {2}{3} i \, \tan \left (x\right ) + \frac {1}{3}\right ) - \frac {1}{4} \, {\rm Li}_2\left (-2 i \, \tan \left (x\right ) - 1\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Both result and optimal contain complex but leaf count of result is larger than twice
the leaf count of optimal. 220 vs. \(2 (50) = 100\).
time = 0.79, size = 220, normalized size = 2.75 \begin {gather*} x \arctan \left (2 \, \tan \left (x\right )\right ) - \frac {1}{4} i \, x \log \left (\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} + 3 i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1}\right ) + \frac {1}{4} i \, x \log \left (\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} + i \, \tan \left (x\right ) + 1\right )}}{3 \, {\left (\tan \left (x\right )^{2} + 1\right )}}\right ) - \frac {1}{4} i \, x \log \left (\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} - i \, \tan \left (x\right ) + 1\right )}}{3 \, {\left (\tan \left (x\right )^{2} + 1\right )}}\right ) + \frac {1}{4} i \, x \log \left (\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} - 3 i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1}\right ) + \frac {1}{8} \, {\rm Li}_2\left (-\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} + 3 i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1} + 1\right ) - \frac {1}{8} \, {\rm Li}_2\left (-\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} + i \, \tan \left (x\right ) + 1\right )}}{3 \, {\left (\tan \left (x\right )^{2} + 1\right )}} + 1\right ) - \frac {1}{8} \, {\rm Li}_2\left (-\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} - i \, \tan \left (x\right ) + 1\right )}}{3 \, {\left (\tan \left (x\right )^{2} + 1\right )}} + 1\right ) + \frac {1}{8} \, {\rm Li}_2\left (-\frac {2 \, {\left (2 \, \tan \left (x\right )^{2} - 3 i \, \tan \left (x\right ) - 1\right )}}{\tan \left (x\right )^{2} + 1} + 1\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \operatorname {atan}{\left (2 \tan {\left (x \right )} \right )}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.01 \begin {gather*} \int \mathrm {atan}\left (2\,\mathrm {tan}\left (x\right )\right ) \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________