How I get the nth derivative of the function $y = e^x x^2$ I'm totally confused. Please anyone help me.
$y' = e^x x^2 + 2 e^xx$
$y''= e^x x^2 + 4 e^xx + 2e^x$
$y'''= e^x x^2 + 6 e^xx + 6 e^x$
next $y''''$ but I failed to get any pattern.

Consider the function:
$$f(\lambda,x) = \exp(\lambda x)$$
Then the function you want to differentiate n times w.r.t. x is $ \frac{\partial^2 f}{\partial\lambda^2}$ at $\lambda = 1$. So, we want to evaluate:
$$ \frac{\partial^n}{\partial x^n}\frac{\partial^2 f}{\partial\lambda^2}$$
We can then interchange the order of differentiation to write this as:
$$ \frac{\partial^2}{\partial \lambda^2}\frac{\partial^n f}{\partial x^n}$$
We have:
$$\frac{\partial^n f}{\partial x^n} = \lambda^n \exp(\lambda x)$$
differentiating twice w.r.t. $\lambda$ gives:
$$\left[n(n-1)\lambda^{n-2} + 2 n\lambda^{n-1} x + \lambda^n x^2\right]\exp(\lambda x)$$
Putting $\lambda = 1$ yields the result:
$$\left[n(n-1)+ 2 n x + x^2\right]\exp(x)$$
