Question: $$I=\large \int\_{0}^{\infty}\left(x^2-3x+1\right)e^{-x}\ln^3(x)\mathrm dx$$

$$e^{-x}=\sum\_{n=0}^{\infty}\frac{(-x)^n}{n!}$$

$$I=\large \sum\_{n=0}^{\infty}\frac{(-1)^n}{n!}\int\_{0}^{\infty}\left(x^2-3x+1\right)x^n\ln^3(x)\mathrm dx$$

$$J=\int \left(x^2-3x+1\right)x^n\ln^3(x)\mathrm dx$$

We can evaluate $J$ by integration by parts but problem, the limits does not work.

**How to evaluate integral $I?$**

Answer: 
Though it's not good practice, we will ignore any constants when evaluating indefinite integrals, as the end result is definite.

**Step I:**

Let's start with the integral $$G\_1=\int\ln x\,dx=x(\ln x-1).$$ Integration by parts gives $$G\_2=\int\ln^2x\,dx=[x\ln x(\ln x-1)]-\int(\ln x-1)\,dx=x(\ln^2x-2\ln x+2)$$ and similarly, $$G\_3=\int\ln^3x\,dx=x(\ln^3x-3\ln^2x+6\ln x-6)$$ 

**Step II:**

Consider the integral $$H\_1=\int\frac{\ln x}{e^x}\,dx.$$ Integration by parts gives $$H\_1=\left[\frac{G\_1}{e^x}\right]+\int\frac{x(\ln x-1)}{e^x}\,dx\implies I\_1=\int\frac{x\ln x}{e^x}\,dx=H\_1-\frac{G\_1}{e^x}+\int\frac x{e^x}\,dx$$ Similarly, if we denote $I\_n$ as the integral of $xe^{-x}\ln^nx$ and $H\_n$ as the integral of $e^{-x}\ln^nx$, we get $$I\_2=H\_2-\frac{G\_2}{e^x}+2I\_1-2\int\frac x{e^x}\,dx$$ and $$I\_3=H\_3-\frac{G\_3}{e^x}+3I\_2-6I\_1+6\int\frac x{e^x}\,dx$$ which can be written as $$I\_3=H\_3+3H\_2-\frac1{e^x}(G\_3-3G\_2)$$

**Step III:**

Now integrate by parts $I\_3$. We will integrate the polynomial part of the integrand ($x$) and differentiate the rest ($e^{-x}\ln^3x$). So $$I\_3=\left[\frac{x^2\ln^3x}{2e^x}\right]-\int\frac{x\ln^2x(3-x\ln x)}{2e^x}\,dx=\frac{x^2\ln^3x}{2e^x}-\frac32I\_2+\frac12\int\frac{x^2\ln^3x}{e^x}\,dx$$ giving $$J\_3=\int\frac{x^2\ln^3x}{e^x}\,dx=2I\_3+3I\_2-\frac{x^2\ln^3x}{e^x}$$ Hence your indefinite integral is $$K=\int\frac{(x^2-3x+1)\ln^3x}{e^x}\,dx=J\_3-3I\_3+H\_3=\frac1{e^x}(G\_3-3G\_2-x^2\ln^3x)+3H\_2$$
The form of the integral takes on the form of the product of a power function, $e^{-x}$, and an integer power of a logarithm. This allows us to consider the integral

$$ \int\_{0}^{\infty}x^{s-1+\epsilon}\,e^{-x}\,\mathrm{d}x = \int\_{0}^{\infty}x^{s-1}e^{\epsilon\ln x}\,e^{-x}\,\mathrm{d}x = \sum\_{n=0}^{\infty}\frac{\epsilon^{n}}{n!}\int\_{0}^{\infty}x^{s-1}\,e^{-x}\,\ln^{n}x\,\mathrm{d}x. $$

Using the gamma function, this integral is also

$$ \int\_{0}^{\infty}x^{s-1+\epsilon}\,e^{-x}\,\mathrm{d}x = \Gamma(s + \epsilon). $$

Using the recursion relation, we may write this in terms of $\Gamma(1+\epsilon)$, which we have a Taylor series expansion for. For example, with $x^{2}$ in the integrand, $s = 3$, so we get $\Gamma(3+\epsilon) = (2+\epsilon)(1+\epsilon)\Gamma(1+\epsilon)$.

We have rewritten our integral as a coefficient in a series expansion. Our integral needs the coefficient of $\epsilon^{3}$ to get the integral with $\ln^{3}x$. We therefore have to obtain the corresponding $\epsilon^{3}$ coefficient in the expansion of the gamma function $\Gamma(1+\epsilon)$.

The usual way of tackling this integral would be to consider the three terms separately and then keep the appropriate terms, but we can do better by evaluating the gamma function terms directly first, which contribute in the following manner:

$$\begin{align} x^{2} - 3x + 1 &\to \Gamma(3 + \epsilon) - 3\Gamma(2+\epsilon) + \Gamma(1+\epsilon) \\
&\to \left((2+\epsilon)(1+\epsilon) - 3(1+\epsilon) + 1\right)\Gamma(1+\epsilon) \\
&\to \epsilon^{2}\,\Gamma(1 + \epsilon). \end{align}$$

Since all that is left is an $\epsilon^{2}$ out in front, we only need keep terms up to first order in $\epsilon$ in the expansion of the gamma function (where $\gamma$ is the Euler-Mascheroni constant and $\zeta(s)$ is the Riemann zeta function)

$$\begin{align} \ln\Gamma(1 + \epsilon) &= -\gamma\epsilon + \sum\_{k=2}^{\infty}\frac{(-1)^{k}\zeta(k)}{k}\epsilon^{k} \\
\Gamma(1 + \epsilon) &\approx e^{-\gamma\epsilon} \approx 1 - \gamma\epsilon. \end{align}$$

Our coefficient is therefore $-\gamma$. Remembering to multiply by $3! = 6$ to account for the factorial in the original series expansion, our answer is

$$ \int\_{0}^{\infty}\left(x^{2} - 3x + 1\right)e^{-x}\ln^{3}x\,\mathrm{d}x = -6\gamma. $$