\(\int \frac {(32+16 x+2 x^2) \log (-2+x)+(-16+4 x+2 x^2) \log ^2(-2+x)}{-2+x} \, dx\) [6627]

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

Optimal result

Integrand size = 39, antiderivative size = 12 \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx=(4+x)^2 \log ^2(-2+x) \]

[Out]

(4+x)^2*ln(-2+x)^2

Rubi [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(36\) vs. \(2(12)=24\).

Time = 0.24 (sec) , antiderivative size = 36, normalized size of antiderivative = 3.00, number of steps used = 16, number of rules used = 15, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.385, Rules used = {6873, 12, 6874, 45, 2442, 2458, 2372, 2338, 2448, 2436, 2333, 2332, 2437, 2342, 2341} \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx=(2-x)^2 \log ^2(x-2)-12 (2-x) \log ^2(x-2)+36 \log ^2(x-2) \]

[In]

Int[((32 + 16*x + 2*x^2)*Log[-2 + x] + (-16 + 4*x + 2*x^2)*Log[-2 + x]^2)/(-2 + x),x]

[Out]

36*Log[-2 + x]^2 - 12*(2 - x)*Log[-2 + x]^2 + (2 - x)^2*Log[-2 + x]^2

Rule 12

Int[(a_)*(u_), x_Symbol] :> Dist[a, Int[u, x], x] /; FreeQ[a, x] &&  !MatchQ[u, (b_)*(v_) /; FreeQ[b, x]]

Rule 45

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.), x_Symbol] :> Int[ExpandIntegrand[(a + b*x)^m*(c + d
*x)^n, x], x] /; FreeQ[{a, b, c, d, n}, x] && NeQ[b*c - a*d, 0] && IGtQ[m, 0] && ( !IntegerQ[n] || (EqQ[c, 0]
&& LeQ[7*m + 4*n + 4, 0]) || LtQ[9*m + 5*(n + 1), 0] || GtQ[m + n + 2, 0])

Rule 2332

Int[Log[(c_.)*(x_)^(n_.)], x_Symbol] :> Simp[x*Log[c*x^n], x] - Simp[n*x, x] /; FreeQ[{c, n}, x]

Rule 2333

Int[((a_.) + Log[(c_.)*(x_)^(n_.)]*(b_.))^(p_.), x_Symbol] :> Simp[x*(a + b*Log[c*x^n])^p, x] - Dist[b*n*p, In
t[(a + b*Log[c*x^n])^(p - 1), x], x] /; FreeQ[{a, b, c, n}, x] && GtQ[p, 0] && IntegerQ[2*p]

Rule 2338

Int[((a_.) + Log[(c_.)*(x_)^(n_.)]*(b_.))/(x_), x_Symbol] :> Simp[(a + b*Log[c*x^n])^2/(2*b*n), x] /; FreeQ[{a
, b, c, n}, x]

Rule 2341

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

Rule 2342

Int[((a_.) + Log[(c_.)*(x_)^(n_.)]*(b_.))^(p_.)*((d_.)*(x_))^(m_.), x_Symbol] :> Simp[(d*x)^(m + 1)*((a + b*Lo
g[c*x^n])^p/(d*(m + 1))), x] - Dist[b*n*(p/(m + 1)), Int[(d*x)^m*(a + b*Log[c*x^n])^(p - 1), x], x] /; FreeQ[{
a, b, c, d, m, n}, x] && NeQ[m, -1] && GtQ[p, 0]

Rule 2372

Int[((a_.) + Log[(c_.)*(x_)^(n_.)]*(b_.))*(x_)^(m_.)*((d_) + (e_.)*(x_)^(r_.))^(q_.), x_Symbol] :> With[{u = I
ntHide[x^m*(d + e*x^r)^q, x]}, Dist[a + b*Log[c*x^n], u, x] - Dist[b*n, Int[SimplifyIntegrand[u/x, x], x], x]]
 /; FreeQ[{a, b, c, d, e, n, r}, x] && IGtQ[q, 0] && IntegerQ[m] &&  !(EqQ[q, 1] && EqQ[m, -1])

Rule 2436

Int[((a_.) + Log[(c_.)*((d_) + (e_.)*(x_))^(n_.)]*(b_.))^(p_.), x_Symbol] :> Dist[1/e, Subst[Int[(a + b*Log[c*
x^n])^p, x], x, d + e*x], x] /; FreeQ[{a, b, c, d, e, n, p}, x]

Rule 2437

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

Rule 2442

Int[((a_.) + Log[(c_.)*((d_) + (e_.)*(x_))^(n_.)]*(b_.))*((f_.) + (g_.)*(x_))^(q_.), x_Symbol] :> Simp[(f + g*
x)^(q + 1)*((a + b*Log[c*(d + e*x)^n])/(g*(q + 1))), x] - Dist[b*e*(n/(g*(q + 1))), Int[(f + g*x)^(q + 1)/(d +
 e*x), x], x] /; FreeQ[{a, b, c, d, e, f, g, n, q}, x] && NeQ[e*f - d*g, 0] && NeQ[q, -1]

Rule 2448

Int[((a_.) + Log[(c_.)*((d_) + (e_.)*(x_))^(n_.)]*(b_.))^(p_)*((f_.) + (g_.)*(x_))^(q_.), x_Symbol] :> Int[Exp
andIntegrand[(f + g*x)^q*(a + b*Log[c*(d + e*x)^n])^p, x], x] /; FreeQ[{a, b, c, d, e, f, g, n, p}, x] && NeQ[
e*f - d*g, 0] && IGtQ[q, 0]

Rule 2458

Int[((a_.) + Log[(c_.)*((d_) + (e_.)*(x_))^(n_.)]*(b_.))^(p_.)*((f_.) + (g_.)*(x_))^(q_.)*((h_.) + (i_.)*(x_))
^(r_.), x_Symbol] :> Dist[1/e, Subst[Int[(g*(x/e))^q*((e*h - d*i)/e + i*(x/e))^r*(a + b*Log[c*x^n])^p, x], x,
d + e*x], x] /; FreeQ[{a, b, c, d, e, f, g, h, i, n, p, q, r}, x] && EqQ[e*f - d*g, 0] && (IGtQ[p, 0] || IGtQ[
r, 0]) && IntegerQ[2*r]

Rule 6873

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

Rule 6874

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

Rubi steps \begin{align*} \text {integral}& = \int \frac {2 (4+x) \log (-2+x) (-4-x+2 \log (-2+x)-x \log (-2+x))}{2-x} \, dx \\ & = 2 \int \frac {(4+x) \log (-2+x) (-4-x+2 \log (-2+x)-x \log (-2+x))}{2-x} \, dx \\ & = 2 \int \left (\frac {(4+x)^2 \log (-2+x)}{-2+x}+(4+x) \log ^2(-2+x)\right ) \, dx \\ & = 2 \int \frac {(4+x)^2 \log (-2+x)}{-2+x} \, dx+2 \int (4+x) \log ^2(-2+x) \, dx \\ & = 2 \int \left (6 \log ^2(-2+x)+(-2+x) \log ^2(-2+x)\right ) \, dx+2 \text {Subst}\left (\int \frac {(6+x)^2 \log (x)}{x} \, dx,x,-2+x\right ) \\ & = -24 (2-x) \log (-2+x)+(2-x)^2 \log (-2+x)+72 \log ^2(-2+x)+2 \int (-2+x) \log ^2(-2+x) \, dx-2 \text {Subst}\left (\int \left (12+\frac {x}{2}+\frac {36 \log (x)}{x}\right ) \, dx,x,-2+x\right )+12 \int \log ^2(-2+x) \, dx \\ & = -\frac {1}{2} (2-x)^2-24 x-24 (2-x) \log (-2+x)+(2-x)^2 \log (-2+x)+72 \log ^2(-2+x)+2 \text {Subst}\left (\int x \log ^2(x) \, dx,x,-2+x\right )+12 \text {Subst}\left (\int \log ^2(x) \, dx,x,-2+x\right )-72 \text {Subst}\left (\int \frac {\log (x)}{x} \, dx,x,-2+x\right ) \\ & = -\frac {1}{2} (2-x)^2-24 x-24 (2-x) \log (-2+x)+(2-x)^2 \log (-2+x)+36 \log ^2(-2+x)-12 (2-x) \log ^2(-2+x)+(2-x)^2 \log ^2(-2+x)-2 \text {Subst}(\int x \log (x) \, dx,x,-2+x)-24 \text {Subst}(\int \log (x) \, dx,x,-2+x) \\ & = 36 \log ^2(-2+x)-12 (2-x) \log ^2(-2+x)+(2-x)^2 \log ^2(-2+x) \\ \end{align*}

Mathematica [B] (verified)

Leaf count is larger than twice the leaf count of optimal. \(47\) vs. \(2(12)=24\).

Time = 0.06 (sec) , antiderivative size = 47, normalized size of antiderivative = 3.92 \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx=2 \left (-2 \log (2-x)+2 \log (-2+x)+8 \log ^2(-2+x)+4 x \log ^2(-2+x)+\frac {1}{2} x^2 \log ^2(-2+x)\right ) \]

[In]

Integrate[((32 + 16*x + 2*x^2)*Log[-2 + x] + (-16 + 4*x + 2*x^2)*Log[-2 + x]^2)/(-2 + x),x]

[Out]

2*(-2*Log[2 - x] + 2*Log[-2 + x] + 8*Log[-2 + x]^2 + 4*x*Log[-2 + x]^2 + (x^2*Log[-2 + x]^2)/2)

Maple [A] (verified)

Time = 0.41 (sec) , antiderivative size = 16, normalized size of antiderivative = 1.33

method result size
risch \(\left (x^{2}+8 x +16\right ) \ln \left (-2+x \right )^{2}\) \(16\)
norman \(\ln \left (-2+x \right )^{2} x^{2}+16 \ln \left (-2+x \right )^{2}+8 \ln \left (-2+x \right )^{2} x\) \(29\)
parallelrisch \(\ln \left (-2+x \right )^{2} x^{2}+16 \ln \left (-2+x \right )^{2}+8 \ln \left (-2+x \right )^{2} x\) \(29\)
derivativedivides \(\left (-2+x \right )^{2} \ln \left (-2+x \right )^{2}+12 \left (-2+x \right ) \ln \left (-2+x \right )^{2}+36 \ln \left (-2+x \right )^{2}\) \(33\)
default \(\left (-2+x \right )^{2} \ln \left (-2+x \right )^{2}+12 \left (-2+x \right ) \ln \left (-2+x \right )^{2}+36 \ln \left (-2+x \right )^{2}\) \(33\)
parts \(\left (-2+x \right )^{2} \ln \left (-2+x \right )^{2}+12 \left (-2+x \right ) \ln \left (-2+x \right )^{2}+36 \ln \left (-2+x \right )^{2}\) \(33\)

[In]

int(((2*x^2+4*x-16)*ln(-2+x)^2+(2*x^2+16*x+32)*ln(-2+x))/(-2+x),x,method=_RETURNVERBOSE)

[Out]

(x^2+8*x+16)*ln(-2+x)^2

Fricas [A] (verification not implemented)

none

Time = 0.56 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.25 \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx={\left (x^{2} + 8 \, x + 16\right )} \log \left (x - 2\right )^{2} \]

[In]

integrate(((2*x^2+4*x-16)*log(-2+x)^2+(2*x^2+16*x+32)*log(-2+x))/(-2+x),x, algorithm="fricas")

[Out]

(x^2 + 8*x + 16)*log(x - 2)^2

Sympy [A] (verification not implemented)

Time = 0.07 (sec) , antiderivative size = 14, normalized size of antiderivative = 1.17 \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx=\left (x^{2} + 8 x + 16\right ) \log {\left (x - 2 \right )}^{2} \]

[In]

integrate(((2*x**2+4*x-16)*ln(-2+x)**2+(2*x**2+16*x+32)*ln(-2+x))/(-2+x),x)

[Out]

(x**2 + 8*x + 16)*log(x - 2)**2

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 97 vs. \(2 (12) = 24\).

Time = 0.19 (sec) , antiderivative size = 97, normalized size of antiderivative = 8.08 \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx=\frac {1}{2} \, {\left (2 \, \log \left (x - 2\right )^{2} - 2 \, \log \left (x - 2\right ) + 1\right )} {\left (x - 2\right )}^{2} + 12 \, {\left (\log \left (x - 2\right )^{2} - 2 \, \log \left (x - 2\right ) + 2\right )} {\left (x - 2\right )} - \frac {1}{2} \, x^{2} + {\left (x^{2} + 4 \, x + 8 \, \log \left (x - 2\right )\right )} \log \left (x - 2\right ) + 16 \, {\left (x + 2 \, \log \left (x - 2\right )\right )} \log \left (x - 2\right ) - 4 \, \log \left (x - 2\right )^{2} - 22 \, x - 44 \, \log \left (x - 2\right ) \]

[In]

integrate(((2*x^2+4*x-16)*log(-2+x)^2+(2*x^2+16*x+32)*log(-2+x))/(-2+x),x, algorithm="maxima")

[Out]

1/2*(2*log(x - 2)^2 - 2*log(x - 2) + 1)*(x - 2)^2 + 12*(log(x - 2)^2 - 2*log(x - 2) + 2)*(x - 2) - 1/2*x^2 + (
x^2 + 4*x + 8*log(x - 2))*log(x - 2) + 16*(x + 2*log(x - 2))*log(x - 2) - 4*log(x - 2)^2 - 22*x - 44*log(x - 2
)

Giac [A] (verification not implemented)

none

Time = 0.29 (sec) , antiderivative size = 15, normalized size of antiderivative = 1.25 \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx={\left (x^{2} + 8 \, x + 16\right )} \log \left (x - 2\right )^{2} \]

[In]

integrate(((2*x^2+4*x-16)*log(-2+x)^2+(2*x^2+16*x+32)*log(-2+x))/(-2+x),x, algorithm="giac")

[Out]

(x^2 + 8*x + 16)*log(x - 2)^2

Mupad [B] (verification not implemented)

Time = 11.35 (sec) , antiderivative size = 12, normalized size of antiderivative = 1.00 \[ \int \frac {\left (32+16 x+2 x^2\right ) \log (-2+x)+\left (-16+4 x+2 x^2\right ) \log ^2(-2+x)}{-2+x} \, dx={\ln \left (x-2\right )}^2\,{\left (x+4\right )}^2 \]

[In]

int((log(x - 2)*(16*x + 2*x^2 + 32) + log(x - 2)^2*(4*x + 2*x^2 - 16))/(x - 2),x)

[Out]

log(x - 2)^2*(x + 4)^2