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

Optimal. Leaf size=53 \[ \frac {1}{12} \left (6 x^2+2 x^3+\left (4-3 x-2 x^2\right ) \sqrt {1+x^2}-3 \sinh ^{-1}(x)-6 \log \left (1+\sqrt {1+x^2}\right )\right ) \]

[Out]

1/2*x^2+1/6*x^3-1/4*arcsinh(x)-1/2*ln(1+(x^2+1)^(1/2))+1/12*(-2*x^2-3*x+4)*(x^2+1)^(1/2)

________________________________________________________________________________________

Rubi [A]
time = 0.14, antiderivative size = 101, normalized size of antiderivative = 1.91, number of steps used = 12, number of rules used = 6, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {6874, 2142, 907, 201, 221, 267} \begin {gather*} \frac {x^3}{6}+\frac {x^2}{2}-\frac {1}{4} \sqrt {x^2+1} x-\frac {1}{6} \left (x^2+1\right )^{3/2}+\frac {1}{2 \left (\sqrt {x^2+1}+x\right )}+\frac {1}{2} \log \left (\sqrt {x^2+1}+x\right )-\log \left (\sqrt {x^2+1}+x+1\right )+\frac {x}{2}-\frac {1}{4} \sinh ^{-1}(x) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

x/2 + x^2/2 + x^3/6 - (x*Sqrt[1 + x^2])/4 - (1 + x^2)^(3/2)/6 + 1/(2*(x + Sqrt[1 + x^2])) - ArcSinh[x]/4 + Log
[x + Sqrt[1 + x^2]]/2 - Log[1 + x + Sqrt[1 + x^2]]

Rule 201

Int[((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[x*((a + b*x^n)^p/(n*p + 1)), x] + Dist[a*n*(p/(n*p + 1)),
 Int[(a + b*x^n)^(p - 1), x], x] /; FreeQ[{a, b}, x] && IGtQ[n, 0] && GtQ[p, 0] && (IntegerQ[2*p] || (EqQ[n, 2
] && IntegerQ[4*p]) || (EqQ[n, 2] && IntegerQ[3*p]) || LtQ[Denominator[p + 1/n], Denominator[p]])

Rule 221

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

Rule 267

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

Rule 907

Int[((d_.) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_))^(n_)*((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :
> Int[ExpandIntegrand[(d + e*x)^m*(f + g*x)^n*(a + b*x + c*x^2)^p, x], x] /; FreeQ[{a, b, c, d, e, f, g}, x] &
& NeQ[e*f - d*g, 0] && NeQ[b^2 - 4*a*c, 0] && NeQ[c*d^2 - b*d*e + a*e^2, 0] && IntegerQ[p] && ((EqQ[p, 1] && I
ntegersQ[m, n]) || (ILtQ[m, 0] && ILtQ[n, 0]))

Rule 2142

Int[((g_.) + (h_.)*((d_.) + (e_.)*(x_) + (f_.)*Sqrt[(a_) + (c_.)*(x_)^2])^(n_))^(p_.), x_Symbol] :> Dist[1/(2*
e), Subst[Int[(g + h*x^n)^p*((d^2 + a*f^2 - 2*d*x + x^2)/(d - x)^2), x], x, d + e*x + f*Sqrt[a + c*x^2]], x] /
; FreeQ[{a, c, d, e, f, g, h, n}, x] && EqQ[e^2 - c*f^2, 0] && IntegerQ[p]

Rule 6874

Int[u_, x_Symbol] :> With[{v = ExpandIntegrand[u, x]}, Int[v, x] /; SumQ[v]]

Rubi steps

\begin {align*} \int \frac {-1+x+x^2}{1+x+\sqrt {1+x^2}} \, dx &=\int \left (-\frac {1}{1+x+\sqrt {1+x^2}}+\frac {x}{1+x+\sqrt {1+x^2}}+\frac {x^2}{1+x+\sqrt {1+x^2}}\right ) \, dx\\ &=-\int \frac {1}{1+x+\sqrt {1+x^2}} \, dx+\int \frac {x}{1+x+\sqrt {1+x^2}} \, dx+\int \frac {x^2}{1+x+\sqrt {1+x^2}} \, dx\\ &=-\left (\frac {1}{2} \text {Subst}\left (\int \frac {2-2 x+x^2}{(1-x)^2 x} \, dx,x,1+x+\sqrt {1+x^2}\right )\right )+\int \left (\frac {1}{2}+\frac {x}{2}-\frac {\sqrt {1+x^2}}{2}\right ) \, dx+\int \left (\frac {x}{2}+\frac {x^2}{2}-\frac {1}{2} x \sqrt {1+x^2}\right ) \, dx\\ &=\frac {x}{2}+\frac {x^2}{2}+\frac {x^3}{6}-\frac {1}{2} \int \sqrt {1+x^2} \, dx-\frac {1}{2} \int x \sqrt {1+x^2} \, dx-\frac {1}{2} \text {Subst}\left (\int \left (\frac {1}{1-x}+\frac {1}{(-1+x)^2}+\frac {2}{x}\right ) \, dx,x,1+x+\sqrt {1+x^2}\right )\\ &=\frac {x}{2}+\frac {x^2}{2}+\frac {x^3}{6}-\frac {1}{4} x \sqrt {1+x^2}-\frac {1}{6} \left (1+x^2\right )^{3/2}+\frac {1}{2 \left (x+\sqrt {1+x^2}\right )}+\frac {1}{2} \log \left (x+\sqrt {1+x^2}\right )-\log \left (1+x+\sqrt {1+x^2}\right )-\frac {1}{4} \int \frac {1}{\sqrt {1+x^2}} \, dx\\ &=\frac {x}{2}+\frac {x^2}{2}+\frac {x^3}{6}-\frac {1}{4} x \sqrt {1+x^2}-\frac {1}{6} \left (1+x^2\right )^{3/2}+\frac {1}{2 \left (x+\sqrt {1+x^2}\right )}-\frac {1}{4} \sinh ^{-1}(x)+\frac {1}{2} \log \left (x+\sqrt {1+x^2}\right )-\log \left (1+x+\sqrt {1+x^2}\right )\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.15, size = 53, normalized size = 1.00 \begin {gather*} \frac {1}{12} \left (6 x^2+2 x^3+\left (4-3 x-2 x^2\right ) \sqrt {1+x^2}-3 \sinh ^{-1}(x)-6 \log \left (1+\sqrt {1+x^2}\right )\right ) \end {gather*}

Antiderivative was successfully verified.

[In]

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

[Out]

(6*x^2 + 2*x^3 + (4 - 3*x - 2*x^2)*Sqrt[1 + x^2] - 3*ArcSinh[x] - 6*Log[1 + Sqrt[1 + x^2]])/12

________________________________________________________________________________________

Maple [A]
time = 0.07, size = 58, normalized size = 1.09

method result size
default \(\frac {x^{2}}{2}-\frac {\ln \left (x \right )}{2}+\frac {x^{3}}{6}-\frac {x \sqrt {x^{2}+1}}{4}-\frac {\arcsinh \left (x \right )}{4}-\frac {\left (x^{2}+1\right )^{\frac {3}{2}}}{6}+\frac {\sqrt {x^{2}+1}}{2}-\frac {\arctanh \left (\frac {1}{\sqrt {x^{2}+1}}\right )}{2}\) \(58\)
trager \(\frac {\left (x^{2}+4 x +4\right ) \left (-1+x \right )}{6}+\frac {\left (-\frac {1}{3} x^{2}-\frac {1}{2} x +\frac {2}{3}\right ) \sqrt {x^{2}+1}}{2}+\frac {\ln \left (\frac {\sqrt {x^{2}+1}\, x^{2}-x^{3}+2 x \sqrt {x^{2}+1}-2 x^{2}+2 \sqrt {x^{2}+1}-2 x -2}{x^{4}}\right )}{4}\) \(86\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

1/2*x^2-1/2*ln(x)+1/6*x^3-1/4*x*(x^2+1)^(1/2)-1/4*arcsinh(x)-1/6*(x^2+1)^(3/2)+1/2*(x^2+1)^(1/2)-1/2*arctanh(1
/(x^2+1)^(1/2))

________________________________________________________________________________________

Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

1/4*x^2 - 3/56*sqrt(7)*arctan(1/7*sqrt(7)*(4*x + 3)) + 1/4*x + integrate((x^4 + x^3 - x^2)/(4*x^5 + 12*x^4 + 1
9*x^3 + 19*x^2 + (4*x^4 + 12*x^3 + 17*x^2 + 12*x + 4)*sqrt(x^2 + 1) + 12*x + 4), x) - 7/16*log(2*x^2 + 3*x + 2
)

________________________________________________________________________________________

Fricas [A]
time = 0.36, size = 78, normalized size = 1.47 \begin {gather*} \frac {1}{6} \, x^{3} + \frac {1}{2} \, x^{2} - \frac {1}{12} \, {\left (2 \, x^{2} + 3 \, x - 4\right )} \sqrt {x^{2} + 1} - \frac {1}{2} \, \log \left (x\right ) - \frac {1}{2} \, \log \left (-x + \sqrt {x^{2} + 1} + 1\right ) + \frac {1}{4} \, \log \left (-x + \sqrt {x^{2} + 1}\right ) + \frac {1}{2} \, \log \left (-x + \sqrt {x^{2} + 1} - 1\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {x^{2} + x - 1}{x + \sqrt {x^{2} + 1} + 1}\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

Integral((x**2 + x - 1)/(x + sqrt(x**2 + 1) + 1), x)

________________________________________________________________________________________

Giac [A]
time = 4.21, size = 80, normalized size = 1.51 \begin {gather*} \frac {1}{6} \, x^{3} + \frac {1}{2} \, x^{2} - \frac {1}{12} \, {\left ({\left (2 \, x + 3\right )} x - 4\right )} \sqrt {x^{2} + 1} + \frac {1}{4} \, \log \left (-x + \sqrt {x^{2} + 1}\right ) - \frac {1}{2} \, \log \left ({\left | x \right |}\right ) - \frac {1}{2} \, \log \left ({\left | -x + \sqrt {x^{2} + 1} + 1 \right |}\right ) + \frac {1}{2} \, \log \left ({\left | -x + \sqrt {x^{2} + 1} - 1 \right |}\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

1/6*x^3 + 1/2*x^2 - 1/12*((2*x + 3)*x - 4)*sqrt(x^2 + 1) + 1/4*log(-x + sqrt(x^2 + 1)) - 1/2*log(abs(x)) - 1/2
*log(abs(-x + sqrt(x^2 + 1) + 1)) + 1/2*log(abs(-x + sqrt(x^2 + 1) - 1))

________________________________________________________________________________________

Mupad [B]
time = 0.04, size = 52, normalized size = 0.98 \begin {gather*} \frac {x^2}{2}-\frac {\ln \left (x\right )}{2}-\sqrt {x^2+1}\,\left (\frac {x^2}{6}+\frac {x}{4}-\frac {1}{3}\right )-\frac {\mathrm {asinh}\left (x\right )}{4}+\frac {x^3}{6}+\frac {\mathrm {atan}\left (\sqrt {x^2+1}\,1{}\mathrm {i}\right )\,1{}\mathrm {i}}{2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

(atan((x^2 + 1)^(1/2)*1i)*1i)/2 - asinh(x)/4 - log(x)/2 - (x^2 + 1)^(1/2)*(x/4 + x^2/6 - 1/3) + x^2/2 + x^3/6

________________________________________________________________________________________