Suppose, $X$ be a random variable with probability density funciton, $$ f(x) = \begin{cases} 16xe^{-4x}, & x \geq 0; \\ 0, & \text{otherwise} \end{cases} $$ (source)
I tried to find the expected value of $X$, so I integrated $16x^2 e^{-4x}$ from $0$ to $\infty$.
After finding the indefinite integral with $u$-substitution:$-\frac{1}{2}e^{-4x}(8x^2+4x+1)+C$, I tried to compute the integral solution with the aforementioned boundaries and here is where I am not certain whether I calculated it right.
It might have gone wrong when I plugged in $\infty$ for $x$. I get $0-(-1/2)=1/2$. Is this correct or am I supposed to get something undefined and can one even get undefined expected value/mean?
When you subtract something from infinity, isn't it undefined? Same as multiplying $0$ with infinity?
Yes your solution is fine, indeed we have
$$\int_0^\infty 16x^2e^{-4x}dx=\left[-\frac12e^{-4x}(8x^2+4x+1)\right]_0^\infty=0-\left(-\frac12\right)=\frac12$$
More in detail what we are solving is the following limit
$$\lim_{a\to \infty} \int_0^a 16x^2e^{-4x}dx=\lim_{a\to \infty}\left[-\frac12e^{-4x}(8x^2+4x+1)\right]_0^a=0-\left(-\frac12\right)=\frac12$$