Solve $ \int_0^\infty x^n e^{-\lambda x} dx $ by differentiating under integral sign I have only found information regarding doing this by integration by parts. By differentiating under the integral sign, I let
$$I_n = \int_0^\infty x^n e^{-\lambda x} dx $$
and get $\frac{dI_n}{d\lambda} = -I_{n+1} $ and therefore $\frac{dI_n}{d\lambda} = -\frac{n+1}{\lambda} I_n$. Proceeding from here I solve the ODE to get $I_n = Ae^{-\frac{n+1}{\lambda}x}$.
This is clearly wrong. What went wrong? I am unsure how to proceed with this differentiation of the integral approach to solve this problem.
 A: Differentiate under the integral sign $n$ times as follows
$$\int_0^\infty x^n e^{-\lambda x} dx=(-1)^n\frac{d^n}{d\lambda^n} \int_0^\infty e^{-\lambda x} dx=
 (-1)^n\frac{d^n}{d\lambda^n}\frac1\lambda=\frac{n!}{\lambda^{n+1}}
$$
A: Let us differentiate a function
$$
\begin{aligned}
I_n(\lambda) = \int_0^{+\infty}x^ne^{-\lambda x}dx
\end{aligned}
$$
with respect to $\lambda$:
$$
\begin{aligned}
\frac{d}{d\lambda}I_n(\lambda) &= \int_0^{+\infty}x^n\frac{d}{d\lambda}\left(e^{-\lambda x}\right)dx = \int_0^{+\infty}x^n \left(-xe^{-\lambda x}\right)dx = \\
&= \int_0^{+\infty}x^{n+1}d\left(\frac{1}{\lambda}e^{-\lambda x}\right) = \\
&= \underbrace{\left. x^{n+1}\left(\frac{1}{\lambda}e^{-\lambda x}\right)\right|_0^{+\infty}}_{=0}-\int_0^{+\infty}\left(\frac{1}{\lambda}e^{-\lambda x}\right)(n+1)x^ndx = \\
&= -\frac{n+1}{\lambda}\int_0^{+\infty}x^ne^{-\lambda x}dx = -\frac{n+1}{\lambda}I_n(\lambda). 
\end{aligned}
$$
Thus, we have a differential equation for $I_n(\lambda)$:
$$
\begin{aligned}
\frac{d}{d\lambda}I_n(\lambda) = -\frac{n+1}{\lambda}I_n(\lambda) &\Leftrightarrow \frac{dI_n}{I_n} = -(n+1)\frac{d\lambda}{\lambda} \Leftrightarrow \log(I_n) = -(n+1)\log(\lambda) + C \Leftrightarrow \\
&\Leftrightarrow \log(I_n) = \log\left(C\lambda^{-(n+1)}\right) \Leftrightarrow I_n(\lambda) = \frac{C}{\lambda^{n+1}}.
\end{aligned}
$$
So, $I_n(\lambda) = \frac{C}{\lambda^{n+1}}$. To find the constant $C$, one needs an initial condition.
Let us calculate $I_n(1)$. Then, $C = I_n(1)$.
$$
\begin{aligned}
I_n(1) &= I_n = \int_0^{+\infty}x^ne^{-x}dx = \left|\text{integrating by parts}\right| = \\
&= nI_{n-1} = n(n-1)I_{n-2} = \ldots = n!I_0 = \\
&= n!\underbrace{\int_0^{+\infty}e^{-x}dx}_{=1} = n! = C.
\end{aligned}
$$
Finalyy, we have
$$
I_n(\lambda) = \int_0^{+\infty}x^ne^{-\lambda x}dx = \frac{n!}{\lambda^{n+1}}
$$
A: Let us define
$$
I_n = \int\limits_{x = 0}^\infty \ x^n \, e^{-\lambda x} \ dx \tag{1}
$$
Method 1: Using Gamma Functions
Use the substitution
$$
\lambda x = t \ \ \mbox{or} \ \ x = {t \over \lambda} \tag{2}
$$
Then
$$
{dx \over dt} = {1 \over \lambda}
$$
Using the substitution (2), we can express $I_n$ in (1) as
$$
I_n = \int\limits_{t = 0}^\infty \ \left( {t^n \over \lambda^n} \right) \ e^{-t} \ {dt \over \lambda} 
 = {1 \over \lambda^{n + 1}} \ \int\limits_{t = 0}^\infty \ t^n e^{-t} \ dt
$$
It is easy to note that
$$
I_n =  {1 \over \lambda^{n + 1}} \ \int\limits_{t = 0}^\infty \ t^{(n + 1) -1} \ e^{-t} \ dt = {\Gamma(n + 1)  \over \lambda^{n + 1}} \ 
$$
Hence, the integral is evaluated as
$$
I_n = {\Gamma(n + 1)  \over \lambda^{n + 1}}
$$
where $\Gamma(\cdot)$ is the Gamma function.
If $n$ is a non-negative integer, then we deduce that
$$
I_n = {n!  \over \lambda^{n + 1}}
$$
because $\Gamma(n+1) = n!$ for $n \in \mathbf{N}$.
Method 2: Using Integration by Parts
$$
I_n = \int\limits_{x = 0}^\infty \ x^n \, e^{-\lambda x} \ dx \tag{1}
$$
Here, we express the Integral $I_n$ as
$$
I_n = \int\limits_{x = 0}^\infty \ x^n \ d\left[ {e^{-\lambda x} \over -\lambda} \right]
$$
Using Integration by Parts, we evaluate $I_n$ as
$$
I_n = \left[ x^n \left( {e^{-\lambda x} \over -\lambda} \right) 
\right]_0^\infty - 
\int\limits_0^\infty \left( {e^{-\lambda x} \over -\lambda} \right) 
\ \left( n x^{n - 1} \right) \ dx
$$
which can be simplified as
$$
I_n = \left[ 0 - 0 \right] + {n \over \lambda} \ 
\int\limits_0^\infty \ x^{n - 1} e^{-\lambda x} \ dx
$$
That is,
$$
I_n = {n \over \lambda} \ I_{n - 1}
$$
which is an useful recurrence relation.
Proceeding recursively, we obtain
$$
I_n = {n \over \lambda} {(n - 1) \over \lambda} \cdots {1 \over \lambda} \ I_0
$$
That is,
$$ 
I_n = {n! \over \lambda^n} \ {1 \over \lambda} = {n! \over \lambda^{n + 1}}
$$
because $I_0 = 1$.
Note that
$$
I_0= \int\limits_{0}^\infty \ e^{-\lambda x} \ dx =
\left[ {e^{-\lambda x} \over - \lambda} \right]_0^\infty = {1 \over \lambda}.
$$
Hence, both methods yield the same value for $I_n$. $\ \ \ \blacksquare$
