Solve definite integral by parts, "one part at a time" Suppose we have the following definite integral:
$$\int^a_b f(x)g'(x)dx$$
I know I can solve it using the by parts formula to obtain a primitive to then evaluate it in $a$ and subtract the evaluation of the same primitive in $b$.
I was wondering if the integral can also be solved using the by parts formula, calculate a primitive of the second integral (the one obtained applying the by parts formula) and calculating first the second integral in the $[a,b]$ interval and then recalculating the original integral, also in the $[a,b]$ interval of course.
In formulas:
$$\int^a_b f(x)g'(x)dx = f(x)g(x) - \int^a_b f'(x)g(x)dx$$
Then, calling the second integral $y(x) = \int^a_b f'(x)g(x)dx$ and being $Y(x)$ a primitive of the second integral, I wonder if is it ok to write:
$$ \int^a_b f(x)g'(x)dx = f(x)g(x) - \int^a_b f'(x)g(x)dx = [f(x)g(x) -  [Y(x)]^a_b]^a_b = [f(x)g(x) - (Y(a)-Y(b))]^a_b$$
We can then state $Y(a)-Y(b) = k$
$$[f(x)g(x) - (Y(a)-Y(b))]^a_b = [f(x)g(x) - k]^a_b = f(a)g(a)-k - (f(b)g(b)-k) = f(a)g(a)-f(b)g(b)$$
I'm asking this question because I tried to solve an integral both ways and I'm obtaining different results... What am I getting wrong here?
 A: let's consider this integral as firstly as an indefinte integral:
$\int_{}^{}f(x)g'(x)dx$
well this integral will be equal to :
$f(x)g(x)-\int_{}^{}(f'(x)g(x))dx$
if you considered the term $\int_{}^{}(f'(x)g(x))dx$ $=$ $z(x)$  then our original integral will be equal to $f(x)g(x)-z(x)$ and if you considered the definte integral from interval$[a,b]$ will be equal to :
$(f(x)g(x)-z(x))  |_{a}^{b}$
which is equal to : $(f(b)g(b)-z(b))-(f(a)g(a)-z(a))$
what you've written wrong that you've duplicated the term $z(x)$ which made it get cancelled
A: 
$$ \int^a_b f(x)g'(x)dx = f(x)g(x) - \int^a_b f'(x)g(x)dx $$$$= [f(x)g(x) -  [Y(x)]^a_b]^a_b = \mathbf{[f(x)g(x) - (Y(a)-Y(b))]^a_b} $$

is wrong. The correct thing should be $$ \int^a_b f(x)g'(x)dx = f(x)g(x)\Bigg |_b^a-\int^a_b f'(x)g(x)dx $$
 EDIT: This is because $$ \int f(x)g'(x)dx= f(x)g(x) - \int f'(x)g(x)dx $$ so putting the limits we get $$ \int^a_b f(x)g'(x)dx = \left[f(x)g(x)- \int f'(x)g(x)dx \right]^a_b$$$$=(f(a)g(a)-f(b)g(b))-\int^a_b f'(x)g(x)dx $$$$= f(x)g(x)\Bigg |^a_b - \int^a_b f'(x)g(x)dx .$$
