\(\int \frac {-1-2 x+x^2}{(-1+x)^2 (1+x^2)} \, dx\) [205]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 24 \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\frac {1}{-1+x}+\arctan (x)+\log (1-x)-\frac {1}{2} \log \left (1+x^2\right ) \]

[Out]

1/(-1+x)+arctan(x)+ln(1-x)-1/2*ln(x^2+1)

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 24, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.190, Rules used = {1643, 649, 209, 266} \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\arctan (x)-\frac {1}{2} \log \left (x^2+1\right )+\frac {1}{x-1}+\log (1-x) \]

[In]

Int[(-1 - 2*x + x^2)/((-1 + x)^2*(1 + x^2)),x]

[Out]

(-1 + x)^(-1) + ArcTan[x] + Log[1 - x] - Log[1 + x^2]/2

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 266

Int[(x_)^(m_.)/((a_) + (b_.)*(x_)^(n_)), x_Symbol] :> Simp[Log[RemoveContent[a + b*x^n, x]]/(b*n), x] /; FreeQ
[{a, b, m, n}, x] && EqQ[m, n - 1]

Rule 649

Int[((d_) + (e_.)*(x_))/((a_) + (c_.)*(x_)^2), x_Symbol] :> Dist[d, Int[1/(a + c*x^2), x], x] + Dist[e, Int[x/
(a + c*x^2), x], x] /; FreeQ[{a, c, d, e}, x] &&  !NiceSqrtQ[(-a)*c]

Rule 1643

Int[(Pq_)*((d_) + (e_.)*(x_))^(m_.)*((a_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegrand[(d + e*x)^m*
Pq*(a + c*x^2)^p, x], x] /; FreeQ[{a, c, d, e, m}, x] && PolyQ[Pq, x] && IGtQ[p, -2]

Rubi steps \begin{align*} \text {integral}& = \int \left (-\frac {1}{(-1+x)^2}+\frac {1}{-1+x}+\frac {1-x}{1+x^2}\right ) \, dx \\ & = \frac {1}{-1+x}+\log (1-x)+\int \frac {1-x}{1+x^2} \, dx \\ & = \frac {1}{-1+x}+\log (1-x)+\int \frac {1}{1+x^2} \, dx-\int \frac {x}{1+x^2} \, dx \\ & = \frac {1}{-1+x}+\arctan (x)+\log (1-x)-\frac {1}{2} \log \left (1+x^2\right ) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.02 (sec) , antiderivative size = 22, normalized size of antiderivative = 0.92 \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\frac {1}{-1+x}+\arctan (x)+\log (-1+x)-\frac {1}{2} \log \left (1+x^2\right ) \]

[In]

Integrate[(-1 - 2*x + x^2)/((-1 + x)^2*(1 + x^2)),x]

[Out]

(-1 + x)^(-1) + ArcTan[x] + Log[-1 + x] - Log[1 + x^2]/2

Maple [A] (verified)

Time = 0.18 (sec) , antiderivative size = 21, normalized size of antiderivative = 0.88

method result size
default \(\ln \left (-1+x \right )+\frac {1}{-1+x}-\frac {\ln \left (x^{2}+1\right )}{2}+\arctan \left (x \right )\) \(21\)
risch \(\ln \left (-1+x \right )+\frac {1}{-1+x}-\frac {\ln \left (x^{2}+1\right )}{2}+\arctan \left (x \right )\) \(21\)
parallelrisch \(\frac {-i \ln \left (x -i\right ) x +i \ln \left (x +i\right ) x +2 \ln \left (-1+x \right ) x +i \ln \left (x -i\right )-\ln \left (x -i\right ) x -i \ln \left (x +i\right )-\ln \left (x +i\right ) x +2-2 \ln \left (-1+x \right )+\ln \left (x -i\right )+\ln \left (x +i\right )}{-2+2 x}\) \(83\)

[In]

int((x^2-2*x-1)/(-1+x)^2/(x^2+1),x,method=_RETURNVERBOSE)

[Out]

ln(-1+x)+1/(-1+x)-1/2*ln(x^2+1)+arctan(x)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 36, normalized size of antiderivative = 1.50 \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\frac {2 \, {\left (x - 1\right )} \arctan \left (x\right ) - {\left (x - 1\right )} \log \left (x^{2} + 1\right ) + 2 \, {\left (x - 1\right )} \log \left (x - 1\right ) + 2}{2 \, {\left (x - 1\right )}} \]

[In]

integrate((x^2-2*x-1)/(-1+x)^2/(x^2+1),x, algorithm="fricas")

[Out]

1/2*(2*(x - 1)*arctan(x) - (x - 1)*log(x^2 + 1) + 2*(x - 1)*log(x - 1) + 2)/(x - 1)

Sympy [A] (verification not implemented)

Time = 0.07 (sec) , antiderivative size = 20, normalized size of antiderivative = 0.83 \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\log {\left (x - 1 \right )} - \frac {\log {\left (x^{2} + 1 \right )}}{2} + \operatorname {atan}{\left (x \right )} + \frac {1}{x - 1} \]

[In]

integrate((x**2-2*x-1)/(-1+x)**2/(x**2+1),x)

[Out]

log(x - 1) - log(x**2 + 1)/2 + atan(x) + 1/(x - 1)

Maxima [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 20, normalized size of antiderivative = 0.83 \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\frac {1}{x - 1} + \arctan \left (x\right ) - \frac {1}{2} \, \log \left (x^{2} + 1\right ) + \log \left (x - 1\right ) \]

[In]

integrate((x^2-2*x-1)/(-1+x)^2/(x^2+1),x, algorithm="maxima")

[Out]

1/(x - 1) + arctan(x) - 1/2*log(x^2 + 1) + log(x - 1)

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 47 vs. \(2 (22) = 44\).

Time = 0.29 (sec) , antiderivative size = 47, normalized size of antiderivative = 1.96 \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\frac {1}{4} \, \pi - \pi \left \lfloor \frac {\pi + 4 \, \arctan \left (x\right )}{4 \, \pi } + \frac {1}{2} \right \rfloor + \frac {1}{x - 1} + \arctan \left (x\right ) - \frac {1}{2} \, \log \left (\frac {2}{x - 1} + \frac {2}{{\left (x - 1\right )}^{2}} + 1\right ) \]

[In]

integrate((x^2-2*x-1)/(-1+x)^2/(x^2+1),x, algorithm="giac")

[Out]

1/4*pi - pi*floor(1/4*(pi + 4*arctan(x))/pi + 1/2) + 1/(x - 1) + arctan(x) - 1/2*log(2/(x - 1) + 2/(x - 1)^2 +
 1)

Mupad [B] (verification not implemented)

Time = 0.05 (sec) , antiderivative size = 28, normalized size of antiderivative = 1.17 \[ \int \frac {-1-2 x+x^2}{(-1+x)^2 \left (1+x^2\right )} \, dx=\ln \left (x-1\right )+\frac {1}{x-1}+\ln \left (x-\mathrm {i}\right )\,\left (-\frac {1}{2}-\frac {1}{2}{}\mathrm {i}\right )+\ln \left (x+1{}\mathrm {i}\right )\,\left (-\frac {1}{2}+\frac {1}{2}{}\mathrm {i}\right ) \]

[In]

int(-(2*x - x^2 + 1)/((x^2 + 1)*(x - 1)^2),x)

[Out]

log(x - 1) - log(x - 1i)*(1/2 + 1i/2) - log(x + 1i)*(1/2 - 1i/2) + 1/(x - 1)