Remember that \int\ f(x)+-g(x)\ dx=\int\ f(x)\ dx+-\int\ g(x) dx.
We can separate the integral into \int\ xe^(x^2-1)\ dx-\int\ x^2e^x\ dx.
First Integral: \int\ xe^(x^2-1)\ dx
For the first integral, we apply a substitution of u=x^2-1. Then, du=2x\ dx, or dx=(du)/(2x).
We substitute these values into the integral: \int\ (xe^u\ du)/(2x)=\int\ e^u/2\ du=e^u/2+C. Substituting u=x^2-1 in, we get e^(x^2-1)/2+C.
Second Integral: \int\ x^2e^x\ dx
We apply integration by parts here: \int\ u\ dv=uv-\int\ v\ du. Following the LIATE rule, we set u=x^2 and dv=e^x. Then, du=2x and v=e^x.
Substituting these in, we get \int\ x^2e^x\ dx=x^2e^x-\int\ e^x2x\ dx. We use integration by parts again. This time, u=2x, dv=e^x, du=2, and v=e^x.
Then, \int\ e^x\2x\ dx=2xe^x-\int\ 2e^x\ dx=2xe^x-2e^x+C.
We substitute this back in: \int\ x^2e^x\ dx=x^2e^x-\int\ e^x2x\ dx=x^2e^x-2xe^x+2e^x+C.
Finally, we bring everything back together: \int\ xe^(x^2-1)\ dx-\int\ x^2e^x\ dx=e^(x^2-1)/2-x^2e^x+2xe^x-2e^x+C=e^(x^2-1)/2-e^x(x^2-2x+2)+C.
We are given one condition that f(2)=7. Therefore, when x=2, e^(x^2-1)/2-e^x(x^2-2x+2)+C=7. We need to find the constant C such that -2e^2+e^3/2+C=7. Solving this, we get that C=7+2e^2-e^3/2.
Therefore, f(x)=e^(x^2-1)/2-e^x(x^2-2x+2)+2e^2-e^3/2+7.