Integration by parts of $\int_0^x f'(t)dt$? Why is 
$$\int_0^x f'(t)dt=(t-x)f'(t)\bigg|_{t=0 }^{t=x} - \int_0^x (t-x)f''(t)\,dt
  =x f'(0) +  \int_0^x (x-t)f''(t)dt $$
as given here:
https://math.stackexchange.com/a/831376/248602
I'm specifically confused about the $(t-x)$ term.
 A: Hint:
Consider the limit of integration $x$ as a parameter (it does not depends on $t$), so 
$$
\frac{d}{dt}(t-x)=1
$$
and
$$
\int_0^xf'(t)dt=\int_0^xf'(t)d(t-x)
$$
now use the integration by parts.
A: Using the product rule for differentiation,
$$
\frac{d}{dt}((t-x)f'(t))=f'(t)+(t-x)f''(t).
$$
Integrating both sides with respect to $t$ from $t=0$ to $t=x$,
$$
\int_0^x \frac{d}{dt}((t-x)f'(t))dt=\int_0^xf'(t)dt+\int_0^x(t-x)f''(t)dt.
$$
By the Fundamental Theorem of Calculus, we have
$$
(t-x)f'(t))\Big|_0^x=\int_0^xf'(t)dt+\int_0^x(t-x)f''(t)dt.
$$
Rearranging and substituting in the limits, we get
$$
\begin{aligned}
\int_0^xf'(t)dt&=(t-x)f'(t))\Big|_0^x-\int_0^x(t-x)f''(t)dt\\
&=0-xf'(0)-\int_0^x(-1)(x-t)f''(t)dt\\
&=-xf'(0)+\int_0^x(x-t)f''(t)dt.
\end{aligned}
$$
A: You can possibly see this better by considering a generic situation; if you have
$$
\int g(t)h(t)\,dt
$$
and $G$ is any antiderivative of $g$, then integration by parts is
$$
\int g(t)h(t)\,dt=G(t)h(t)-\int G(t)h'(t)\,dt
$$
If we are doing an integral, rather than computing an antiderivative,
$$
\int_a^b g(t)h(t)\,dt=\Bigl[G(t)h(t)\Bigr]_a^b-\int_a^b G(t)h'(t)\,dt
$$
In the situation you're in, you can take $g(t)=1$ and $G(t)=t-c$ for an arbitrary $c$. This is frequently taken to be $0$, but any other value can do as well. That argument uses $c=x$.
By choosing $c=0$, instead, the formula would read
$$
\int_0^x f'(t)dt=\Bigl[tf'(t)\Bigr]_{t=0}^{t=x} - \int_0^x tf''(t)\,dt
  =x f'(x) -  \int_0^x tf''(t)dt
$$
that probably would be less convenient for the rest of the argument.
However, if you differentiate with respect to $x$, you get
\begin{align}
\frac{d}{dx}\left(x f'(0) +  \int_0^x (x-t)f''(t)dt\right)
&=\frac{d}{dx}\left(x f'(0) +  x\int_0^x f''(t)dt- \int_0^x tf''(t)dt\right) \\
&=f'(0)+\int_0^xf''(t)\,dt+xf''(x)-xf''(x) \\
&=f'(0)+f'(x)-f'(0)\\
&=f'(x)
\end{align}
so the integration is correct, because both functions evaluate to $0$ at $0$.
Similarly
$$
\frac{d}{dx}\left(x f'(x) -  \int_0^x tf''(t)dt\right)
= f'(x)+xf''(x)-xf''(x)=f'(x)
$$
