3.1.31 \(\int -\tan (a-x) \tan (x) \, dx\) [31]

Optimal. Leaf size=21 \[ -x+\cot (a) \log (\cos (a-x))-\cot (a) \log (\cos (x)) \]

[Out]

-x-cot(a)*ln(cos(x))+cot(a)*ln(cos(a-x))

________________________________________________________________________________________

Rubi [A]
time = 0.02, antiderivative size = 21, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, integrand size = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.300, Rules used = {4708, 4706, 3556} \begin {gather*} \cot (a) \log (\cos (a-x))-\cot (a) \log (\cos (x))-x \end {gather*}

Antiderivative was successfully verified.

[In]

Int[-(Tan[a - x]*Tan[x]),x]

[Out]

-x + Cot[a]*Log[Cos[a - x]] - Cot[a]*Log[Cos[x]]

Rule 3556

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

Rule 4706

Int[Sec[(a_.) + (b_.)*(x_)]*Sec[(c_) + (d_.)*(x_)], x_Symbol] :> Dist[-Csc[(b*c - a*d)/d], Int[Tan[a + b*x], x
], x] + Dist[Csc[(b*c - a*d)/b], Int[Tan[c + d*x], x], x] /; FreeQ[{a, b, c, d}, x] && EqQ[b^2 - d^2, 0] && Ne
Q[b*c - a*d, 0]

Rule 4708

Int[Tan[(a_.) + (b_.)*(x_)]*Tan[(c_) + (d_.)*(x_)], x_Symbol] :> Simp[(-b)*(x/d), x] + Dist[(b/d)*Cos[(b*c - a
*d)/d], Int[Sec[a + b*x]*Sec[c + d*x], x], x] /; FreeQ[{a, b, c, d}, x] && EqQ[b^2 - d^2, 0] && NeQ[b*c - a*d,
 0]

Rubi steps

\begin {align*} \int -\tan (a-x) \tan (x) \, dx &=-x+\cos (a) \int \sec (a-x) \sec (x) \, dx\\ &=-x+\cot (a) \int \tan (a-x) \, dx+\cot (a) \int \tan (x) \, dx\\ &=-x+\cot (a) \log (\cos (a-x))-\cot (a) \log (\cos (x))\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.06, size = 21, normalized size = 1.00 \begin {gather*} -x+\cot (a) \log (\cos (a-x))-\cot (a) \log (\cos (x)) \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[-(Tan[a - x]*Tan[x]),x]

[Out]

-x + Cot[a]*Log[Cos[a - x]] - Cot[a]*Log[Cos[x]]

________________________________________________________________________________________

Maple [A]
time = 0.07, size = 20, normalized size = 0.95

method result size
derivativedivides \(-\arctan \left (\tan \left (x \right )\right )+\frac {\ln \left (1+\tan \left (x \right ) \tan \left (a \right )\right )}{\tan \left (a \right )}\) \(20\)
default \(-\arctan \left (\tan \left (x \right )\right )+\frac {\ln \left (1+\tan \left (x \right ) \tan \left (a \right )\right )}{\tan \left (a \right )}\) \(20\)
risch \(-x +\frac {i \ln \left ({\mathrm e}^{2 i a}+{\mathrm e}^{2 i x}\right ) {\mathrm e}^{2 i a}}{{\mathrm e}^{2 i a}-1}+\frac {i \ln \left ({\mathrm e}^{2 i a}+{\mathrm e}^{2 i x}\right )}{{\mathrm e}^{2 i a}-1}-\frac {i \ln \left ({\mathrm e}^{2 i x}+1\right ) {\mathrm e}^{2 i a}}{{\mathrm e}^{2 i a}-1}-\frac {i \ln \left ({\mathrm e}^{2 i x}+1\right )}{{\mathrm e}^{2 i a}-1}\) \(103\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(-tan(x)*tan(a-x),x,method=_RETURNVERBOSE)

[Out]

-arctan(tan(x))+1/tan(a)*ln(1+tan(x)*tan(a))

________________________________________________________________________________________

Maxima [B] Leaf count of result is larger than twice the leaf count of optimal. 186 vs. \(2 (21) = 42\).
time = 6.22, size = 186, normalized size = 8.86 \begin {gather*} -\frac {{\left (\cos \left (2 \, a\right )^{2} + \sin \left (2 \, a\right )^{2} - 2 \, \cos \left (2 \, a\right ) + 1\right )} x + {\left (\cos \left (2 \, a\right )^{2} + \sin \left (2 \, a\right )^{2} - 1\right )} \arctan \left (\sin \left (2 \, a\right ) + \sin \left (2 \, x\right ), \cos \left (2 \, a\right ) + \cos \left (2 \, x\right )\right ) - {\left (\cos \left (2 \, a\right )^{2} + \sin \left (2 \, a\right )^{2} - 1\right )} \arctan \left (\sin \left (2 \, x\right ), \cos \left (2 \, x\right ) + 1\right ) - \log \left (\cos \left (2 \, a\right )^{2} + 2 \, \cos \left (2 \, a\right ) \cos \left (2 \, x\right ) + \cos \left (2 \, x\right )^{2} + \sin \left (2 \, a\right )^{2} + 2 \, \sin \left (2 \, a\right ) \sin \left (2 \, x\right ) + \sin \left (2 \, x\right )^{2}\right ) \sin \left (2 \, a\right ) + \log \left (\cos \left (2 \, x\right )^{2} + \sin \left (2 \, x\right )^{2} + 2 \, \cos \left (2 \, x\right ) + 1\right ) \sin \left (2 \, a\right )}{\cos \left (2 \, a\right )^{2} + \sin \left (2 \, a\right )^{2} - 2 \, \cos \left (2 \, a\right ) + 1} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(-tan(x)*tan(a-x),x, algorithm="maxima")

[Out]

-((cos(2*a)^2 + sin(2*a)^2 - 2*cos(2*a) + 1)*x + (cos(2*a)^2 + sin(2*a)^2 - 1)*arctan2(sin(2*a) + sin(2*x), co
s(2*a) + cos(2*x)) - (cos(2*a)^2 + sin(2*a)^2 - 1)*arctan2(sin(2*x), cos(2*x) + 1) - log(cos(2*a)^2 + 2*cos(2*
a)*cos(2*x) + cos(2*x)^2 + sin(2*a)^2 + 2*sin(2*a)*sin(2*x) + sin(2*x)^2)*sin(2*a) + log(cos(2*x)^2 + sin(2*x)
^2 + 2*cos(2*x) + 1)*sin(2*a))/(cos(2*a)^2 + sin(2*a)^2 - 2*cos(2*a) + 1)

________________________________________________________________________________________

Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 89 vs. \(2 (21) = 42\).
time = 0.50, size = 89, normalized size = 4.24 \begin {gather*} \frac {{\left (\cos \left (2 \, a\right ) + 1\right )} \log \left (-\frac {{\left (\cos \left (2 \, a\right ) - 1\right )} \tan \left (x\right )^{2} - 2 \, \sin \left (2 \, a\right ) \tan \left (x\right ) - \cos \left (2 \, a\right ) - 1}{{\left (\cos \left (2 \, a\right ) + 1\right )} \tan \left (x\right )^{2} + \cos \left (2 \, a\right ) + 1}\right ) - {\left (\cos \left (2 \, a\right ) + 1\right )} \log \left (\frac {1}{\tan \left (x\right )^{2} + 1}\right ) - 2 \, x \sin \left (2 \, a\right )}{2 \, \sin \left (2 \, a\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(-tan(x)*tan(a-x),x, algorithm="fricas")

[Out]

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

________________________________________________________________________________________

Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 66 vs. \(2 (19) = 38\).
time = 0.69, size = 138, normalized size = 6.57 \begin {gather*} - \left (\begin {cases} \frac {2 x \tan {\left (a \right )}}{2 \tan ^{2}{\left (a \right )} + 2} - \frac {2 \log {\left (\tan {\left (x \right )} + \frac {1}{\tan {\left (a \right )}} \right )}}{2 \tan ^{2}{\left (a \right )} + 2} + \frac {\log {\left (\tan ^{2}{\left (x \right )} + 1 \right )}}{2 \tan ^{2}{\left (a \right )} + 2} & \text {for}\: a \neq 0 \\\frac {\log {\left (\tan ^{2}{\left (x \right )} + 1 \right )}}{2} & \text {otherwise} \end {cases}\right ) \tan {\left (a \right )} + \begin {cases} - \frac {2 x \tan {\left (a \right )}}{2 \tan ^{3}{\left (a \right )} + 2 \tan {\left (a \right )}} + \frac {2 \log {\left (\tan {\left (x \right )} + \frac {1}{\tan {\left (a \right )}} \right )}}{2 \tan ^{3}{\left (a \right )} + 2 \tan {\left (a \right )}} + \frac {\log {\left (\tan ^{2}{\left (x \right )} + 1 \right )} \tan ^{2}{\left (a \right )}}{2 \tan ^{3}{\left (a \right )} + 2 \tan {\left (a \right )}} & \text {for}\: a \neq 0 \\- x + \tan {\left (x \right )} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(-tan(x)*tan(a-x),x)

[Out]

-Piecewise((2*x*tan(a)/(2*tan(a)**2 + 2) - 2*log(tan(x) + 1/tan(a))/(2*tan(a)**2 + 2) + log(tan(x)**2 + 1)/(2*
tan(a)**2 + 2), Ne(a, 0)), (log(tan(x)**2 + 1)/2, True))*tan(a) + Piecewise((-2*x*tan(a)/(2*tan(a)**3 + 2*tan(
a)) + 2*log(tan(x) + 1/tan(a))/(2*tan(a)**3 + 2*tan(a)) + log(tan(x)**2 + 1)*tan(a)**2/(2*tan(a)**3 + 2*tan(a)
), Ne(a, 0)), (-x + tan(x), True))

________________________________________________________________________________________

Giac [A]
time = 1.10, size = 18, normalized size = 0.86 \begin {gather*} -x + \frac {\log \left ({\left | \tan \left (a\right ) \tan \left (x\right ) + 1 \right |}\right )}{\tan \left (a\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(-tan(x)*tan(a-x),x, algorithm="giac")

[Out]

-x + log(abs(tan(a)*tan(x) + 1))/tan(a)

________________________________________________________________________________________

Mupad [B]
time = 1.33, size = 118, normalized size = 5.62 \begin {gather*} -x-\frac {\frac {\sin \left (2\,a\right )\,\ln \left ({\sin \left (2\,a+x\right )}^2\,2{}\mathrm {i}+{\sin \left (2\,a\right )}^2\,2{}\mathrm {i}-{\sin \left (x\right )}^2\,2{}\mathrm {i}+\sin \left (4\,a\right )-\sin \left (2\,x\right )+\sin \left (4\,a+2\,x\right )\right )}{2}-\frac {\sin \left (2\,a\right )\,\ln \left (\sin \left (2\,a\right )\,\left (2\,{\sin \left (a\right )}^2-1\right )-{\sin \left (2\,a\right )}^2\,1{}\mathrm {i}+\sin \left (2\,a\right )\,\left (2\,{\sin \left (x\right )}^2-1\right )-\sin \left (2\,a\right )\,\sin \left (2\,x\right )\,1{}\mathrm {i}\right )}{2}}{{\sin \left (a\right )}^2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(-tan(a - x)*tan(x),x)

[Out]

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

________________________________________________________________________________________