f(x) = int xe^(x^2-1)dx - intx^2e^(x)dx
For the first integral:
int xe^(x^2-1)dx = intxe^(x^2)*1/edx = 1/eintxe^(x^2)dx
Let u = e^(x^2). The exponential function rule states that
[e^g(x)]' = g'(x)e^g(x) => [e^(x^2)]' = 2xe^(x^2)
In other words, dx = 1/(2xe^(x^2)) du = 1/(2x) * 1/u du.
1/eint xe^(x^2) dx = 1/eint xu * 1/(2xu)du=1/(2e)intdu = 1/(2e)u +C_1 = 1/2 e^(x^2-1)+C_1
For the second one:
intx^2e^xdx
We can solve this by integration by parts.
intalphabeta' = alphabeta - intalpha'beta
In our case, alpha = x^2 => alpha' = 2x and beta' =e^x => beta =e^x. Plug in these functions.
intx^2e^xdx = x^2e^x - 2color(blue)(intxe^xdx
In order to solve the color(blue)("blue") integral, you can use integration by parts, again.
alpha_2 =x => alpha_2' = 1
beta_2' = e^x => beta_2 = e^x
intxe^xdx = xe^x - inte^xdx = xe^x-e^x + C_2 = e^x(x-1) + C_2
Then
intx^2e^xdx = x^2e^x -2e^x(x-1) + C_2 = e^x(x^2-2x+2) + C_2
Therefore, we have:
f(x) = 1/2 e^(x^2-1) + e^x(2x-2-x^2) + C_1 + C_2
However, a constant plus a constant is another constant. Let this be c.
C_1 + C_2 = c
f(x) = 1/2 e^(x^2-1) + e^x(2x-2-x^2) + c
We know that f(color(red)2) = color(blue)4.
f(2) = 1/2 e^(color(red)2^2 - 1) + e^color(red)2(2*color(red)2-2-color(red)2^2) + c = 1/2 e^3 - 2e^2 + c = color(blue)4
Therefore, c = 4- e^2(e/2 + 2).
Finally,
color(red)(f(x)) = 1/2 e^(x^2-1) + e^x(2x-2-x^2) + 4 - 1/2e^3 -2e^2