I'm reading about "integration by parts", and I have a hard time understanding why in the below example they do the procedure 3 times. Or maybe better put, when do you know that you have to do integration by parts more in order to be finished? Function to be integrated Step by step how the book does it
Can't you just simply say that you are finish integrating, when we obtain the integral for the last "remainder" part, which in this example was xe^2x in part **?
The answer to "When do you stop integrating?" is "When you have something you know how to integrate".
Do you, inherently, know what $\int x^3 e^x dx$ is? It doesn't normally appear on a table of standard integrals. We do know how to find $\int x^3 dx$ and $\int e^x dx$, though, and so the aim of using IBP is to hopefully make use of these integrals we do know somehow.
If we apply IBP in the direction shown in the textbook, we find that we're left with a term like $\int x^2 e^x dx$, and while it still isn't something we can read off a table, we notice that we've reduced the $x^3$ to $x^2$ and intuitively we can see that if we repeat the process we're likely to keep reducing the exponent of $x$ - from $x^3$ to $x^2$ to $x$ to just a constant, and once we do that we know we'll be left with just the nice simple integral $\int e^x dx$.
Now we could apply IBP the other way around - treating $x^3$ as the $g'$ and $e^x$ as the $f$. But what we find if we do that is that we end up increasing the exponent of the polynomial term - we go from $x^3$ to $x^4$, and if we continue in that direction we're just going to get increasingly more complicated integrals that we don't know how to approach.
A lot of integration is like this - applying techniques like substitution and integration by parts to transform an ugly integral into something more familiar. Sometimes, it takes a mix of experience and trial-and-error to get to the answer.