3.24 \(\int \frac{(1-\sqrt{x}+x)^2}{x^2} \, dx\)

Optimal. Leaf size=25 \[ x-4 \sqrt{x}+\frac{4}{\sqrt{x}}-\frac{1}{x}+3 \log (x) \]

[Out]

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

________________________________________________________________________________________

Rubi [A]  time = 0.0184495, antiderivative size = 25, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 2, integrand size = 16, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.125, Rules used = {1357, 698} \[ x-4 \sqrt{x}+\frac{4}{\sqrt{x}}-\frac{1}{x}+3 \log (x) \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

Rule 1357

Int[(x_)^(m_.)*((a_) + (c_.)*(x_)^(n2_.) + (b_.)*(x_)^(n_))^(p_.), x_Symbol] :> Dist[1/n, Subst[Int[x^(Simplif
y[(m + 1)/n] - 1)*(a + b*x + c*x^2)^p, x], x, x^n], x] /; FreeQ[{a, b, c, m, n, p}, x] && EqQ[n2, 2*n] && NeQ[
b^2 - 4*a*c, 0] && IntegerQ[Simplify[(m + 1)/n]]

Rule 698

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

Rubi steps

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

Mathematica [A]  time = 0.0129274, size = 25, normalized size = 1. \[ x-4 \sqrt{x}+\frac{4}{\sqrt{x}}-\frac{1}{x}+3 \log (x) \]

Antiderivative was successfully verified.

[In]

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

[Out]

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

________________________________________________________________________________________

Maple [A]  time = 0.008, size = 22, normalized size = 0.9 \begin{align*} -{x}^{-1}+x+3\,\ln \left ( x \right ) +4\,{\frac{1}{\sqrt{x}}}-4\,\sqrt{x} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Maxima [A]  time = 0.929867, size = 30, normalized size = 1.2 \begin{align*} x - 4 \, \sqrt{x} + \frac{4 \, \sqrt{x} - 1}{x} + 3 \, \log \left (x\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

x - 4*sqrt(x) + (4*sqrt(x) - 1)/x + 3*log(x)

________________________________________________________________________________________

Fricas [A]  time = 2.18741, size = 70, normalized size = 2.8 \begin{align*} \frac{x^{2} + 6 \, x \log \left (\sqrt{x}\right ) - 4 \,{\left (x - 1\right )} \sqrt{x} - 1}{x} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

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

________________________________________________________________________________________

Sympy [A]  time = 0.402118, size = 22, normalized size = 0.88 \begin{align*} - 4 \sqrt{x} + x + 3 \log{\left (x \right )} - \frac{1}{x} + \frac{4}{\sqrt{x}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

-4*sqrt(x) + x + 3*log(x) - 1/x + 4/sqrt(x)

________________________________________________________________________________________

Giac [A]  time = 1.05138, size = 31, normalized size = 1.24 \begin{align*} x - 4 \, \sqrt{x} + \frac{4 \, \sqrt{x} - 1}{x} + 3 \, \log \left ({\left | x \right |}\right ) \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

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

[Out]

x - 4*sqrt(x) + (4*sqrt(x) - 1)/x + 3*log(abs(x))