#f(x) = int (x e^x - x)dx#
#=>f(x) = int xe^xdx - int x dx#
#=>f(x) = int x e^x dx - 1/2 x^2 + C_2#
where #C_2# is an arbitrary constant of integration.
To solve the first integral, we will employ integration by parts. Let #u equiv x# and #dv equiv e^xdx#.
#int x e^x dx = uv - int v du#
#=>int x e^x dx = xe^x - int e^x dx + C_1#
#=>int xe^x dx = xe^x - e^x + C_1#
#=>int xe^x dx = color(blue)(e^x(x - 1) + C_1)#
where #C_1# is an arbitrary constant of integration.
We can now substitute this result back into our #f(x)#.
#f(x) = color(blue)(e^x(x - 1) + C_1) - 1/2x^2 + C_2#
#=>f(x) = e^x(x-1)-1/2x^2 + C#
where #C# is an arbitrary constant of integration (#C_1# and #C_2# were arbitrary, so they were combined into a single constant term).
Assessing at #f(0)#:
#f(0) = -2 = e^0(0-1)-1/2(0)^2+C#
#=>-2 = -1 +C#
#=>C = -1#
Hence, the final result is:
#=>color(green)(f(x) = e^x(x-1)-1/2x^2 -1)#