### 3.174 $$\int \frac{2-x+x^2}{-5+2 x+x^2} \, dx$$

Optimal. Leaf size=48 $x-\frac{1}{6} \left (9-5 \sqrt{6}\right ) \log \left (x-\sqrt{6}+1\right )-\frac{1}{6} \left (9+5 \sqrt{6}\right ) \log \left (x+\sqrt{6}+1\right )$

[Out]

x - ((9 - 5*Sqrt[6])*Log[1 - Sqrt[6] + x])/6 - ((9 + 5*Sqrt[6])*Log[1 + Sqrt[6] + x])/6

________________________________________________________________________________________

Rubi [A]  time = 0.0446019, antiderivative size = 48, normalized size of antiderivative = 1., number of steps used = 5, number of rules used = 3, integrand size = 19, $$\frac{\text{number of rules}}{\text{integrand size}}$$ = 0.158, Rules used = {1657, 632, 31} $x-\frac{1}{6} \left (9-5 \sqrt{6}\right ) \log \left (x-\sqrt{6}+1\right )-\frac{1}{6} \left (9+5 \sqrt{6}\right ) \log \left (x+\sqrt{6}+1\right )$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

x - ((9 - 5*Sqrt[6])*Log[1 - Sqrt[6] + x])/6 - ((9 + 5*Sqrt[6])*Log[1 + Sqrt[6] + x])/6

Rule 1657

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

Rule 632

Int[((d_.) + (e_.)*(x_))/((a_) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> With[{q = Rt[b^2 - 4*a*c, 2]}, Dist[
(c*d - e*(b/2 - q/2))/q, Int[1/(b/2 - q/2 + c*x), x], x] - Dist[(c*d - e*(b/2 + q/2))/q, Int[1/(b/2 + q/2 + c*
x), x], x]] /; FreeQ[{a, b, c, d, e}, x] && NeQ[2*c*d - b*e, 0] && NeQ[b^2 - 4*a*c, 0] && NiceSqrtQ[b^2 - 4*a*
c]

Rule 31

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

Rubi steps

\begin{align*} \int \frac{2-x+x^2}{-5+2 x+x^2} \, dx &=\int \left (1+\frac{7-3 x}{-5+2 x+x^2}\right ) \, dx\\ &=x+\int \frac{7-3 x}{-5+2 x+x^2} \, dx\\ &=x+\frac{1}{6} \left (-9+5 \sqrt{6}\right ) \int \frac{1}{1-\sqrt{6}+x} \, dx-\frac{1}{6} \left (9+5 \sqrt{6}\right ) \int \frac{1}{1+\sqrt{6}+x} \, dx\\ &=x-\frac{1}{6} \left (9-5 \sqrt{6}\right ) \log \left (1-\sqrt{6}+x\right )-\frac{1}{6} \left (9+5 \sqrt{6}\right ) \log \left (1+\sqrt{6}+x\right )\\ \end{align*}

Mathematica [A]  time = 0.038973, size = 48, normalized size = 1. $x+\frac{1}{6} \left (5 \sqrt{6}-9\right ) \log \left (-x+\sqrt{6}-1\right )+\frac{1}{6} \left (-9-5 \sqrt{6}\right ) \log \left (x+\sqrt{6}+1\right )$

Antiderivative was successfully veriﬁed.

[In]

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

[Out]

x + ((-9 + 5*Sqrt[6])*Log[-1 + Sqrt[6] - x])/6 + ((-9 - 5*Sqrt[6])*Log[1 + Sqrt[6] + x])/6

________________________________________________________________________________________

Maple [A]  time = 0.05, size = 30, normalized size = 0.6 \begin{align*} x-{\frac{3\,\ln \left ({x}^{2}+2\,x-5 \right ) }{2}}-{\frac{5\,\sqrt{6}}{3}{\it Artanh} \left ({\frac{ \left ( 2\,x+2 \right ) \sqrt{6}}{12}} \right ) } \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

x-3/2*ln(x^2+2*x-5)-5/3*6^(1/2)*arctanh(1/12*(2*x+2)*6^(1/2))

________________________________________________________________________________________

Maxima [A]  time = 1.57666, size = 49, normalized size = 1.02 \begin{align*} \frac{5}{6} \, \sqrt{6} \log \left (\frac{x - \sqrt{6} + 1}{x + \sqrt{6} + 1}\right ) + x - \frac{3}{2} \, \log \left (x^{2} + 2 \, x - 5\right ) \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

5/6*sqrt(6)*log((x - sqrt(6) + 1)/(x + sqrt(6) + 1)) + x - 3/2*log(x^2 + 2*x - 5)

________________________________________________________________________________________

Fricas [A]  time = 1.76941, size = 157, normalized size = 3.27 \begin{align*} \frac{5}{6} \, \sqrt{3} \sqrt{2} \log \left (-\frac{2 \, \sqrt{3} \sqrt{2}{\left (x + 1\right )} - x^{2} - 2 \, x - 7}{x^{2} + 2 \, x - 5}\right ) + x - \frac{3}{2} \, \log \left (x^{2} + 2 \, x - 5\right ) \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

5/6*sqrt(3)*sqrt(2)*log(-(2*sqrt(3)*sqrt(2)*(x + 1) - x^2 - 2*x - 7)/(x^2 + 2*x - 5)) + x - 3/2*log(x^2 + 2*x
- 5)

________________________________________________________________________________________

Sympy [A]  time = 0.112266, size = 46, normalized size = 0.96 \begin{align*} x + \left (- \frac{5 \sqrt{6}}{6} - \frac{3}{2}\right ) \log{\left (x + 1 + \sqrt{6} \right )} + \left (- \frac{3}{2} + \frac{5 \sqrt{6}}{6}\right ) \log{\left (x - \sqrt{6} + 1 \right )} \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

x + (-5*sqrt(6)/6 - 3/2)*log(x + 1 + sqrt(6)) + (-3/2 + 5*sqrt(6)/6)*log(x - sqrt(6) + 1)

________________________________________________________________________________________

Giac [A]  time = 1.16208, size = 61, normalized size = 1.27 \begin{align*} \frac{5}{6} \, \sqrt{6} \log \left (\frac{{\left | 2 \, x - 2 \, \sqrt{6} + 2 \right |}}{{\left | 2 \, x + 2 \, \sqrt{6} + 2 \right |}}\right ) + x - \frac{3}{2} \, \log \left ({\left | x^{2} + 2 \, x - 5 \right |}\right ) \end{align*}

Veriﬁcation of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

5/6*sqrt(6)*log(abs(2*x - 2*sqrt(6) + 2)/abs(2*x + 2*sqrt(6) + 2)) + x - 3/2*log(abs(x^2 + 2*x - 5))