Let, #I=int(x^2+1)e^-xdx#.
Using the following Rule of Integration by Parts (IBP) :
IBP : #intuv'dx=uv-intvu'dx#.
We take, #u=x^2+1, and, v'=e^-x#.
#:. u'=2x, and, v=inte^-xdx=e^-x/-1=-e^-x#.
#:. I=-(x^2+1)e^-x-int(-e^-x*2x)dx#,
#rArr I=-(x^2+1)e^-x+2I_1," where, "I_1=intxe^-xdx#.
We once again use IBP for #I_1#; this time, we choose,
#u=x, and, v'=e^-x :. u'=1, and, v=-e^-x#.
#:. I_1=-xe^-x-int(-e^-x*1)dx#,
#: I_1=-xe^-x-e^-x#.
Utilising #I_1# in #I#, we get,
#I=-(x^2+1)e^-x+2{-xe^-x-e^-x}#,
# rArr I=-(x^2+2x+3)e^-x+C#.
#:. int_0^1(x^2+1)e^-xdx=-[(x^2+2x+3)e^-x]_0^1#,
#=-[(1+2+3)e^-1-(0+0+3)e^-0]#.
# rArr int_0^1(x^2+1)e^-xdx=-(6/e-3)=3/e(e-2)#.
Enjoy Maths.!