When you differentiate f(x)*e^u(x) say, you will always get e^u(x) in the answer, as a factor. i.e. the answer will be of the form g(x)*e^u(x).
Since we already have (x^2+2x-1)exp(x+1/x) after having differentiated say, then we would have started with something like h(x)*exp(x+1/x), where h(x) is some function that we have to find.
Since x^2 + 2x - 1 is a quadratic polynomial, then let h(x) = ax^2 + bx + c, another quadratic polynomial, be a possible solution to the integration.
Differentiate (ax^2 + bx + c)*exp(x+1/x), to give
(2ax + b)*exp(x+1/x), + (ax^2 + bx + c)*(1-1/x^2)*exp(x+1/x),
exp(x+1/x){(2ax+b)(x^2/x^2) + (ax^2 + bx + c)(x^2-1)/x^2}
exp(x+1/x)/(x^2){(2ax+b)(x^2) + (ax^2 + bx + c)(x^2-1)}
exp(x+1/x)/(x^2){2ax^3+bx^2 + ax^4 + bx^3 + cx^2 - ax^2 - bx - c}
exp(x+1/x)/(x^2){ax^4 + (b + 2a)x^3 + (b + c - a)x^2 - bx - c}
since the quartic polynomial must be divisible by x^2, then we must have b = c = 0.
exp(x+1/x)/(x^2){ax^4 + (2a)x^3 + (- a)x^2}
exp(x+1/x){ax^2 + 2ax - a}
Hence a = 1 satisfies the original expresion that we had to integrate.
Putting a = 1, b = 0, c = 0 into the solution, (ax^2 + bx + c)*exp(x+1/x), this gives,
Answer: x^2*exp(x+1/x)