Second Fundamental Theorem of Calculus... Let $f$ have a continuous second derivative. Prove that
$$f(x) = f(a) + (x - a)f'(a) + \int_a^x(x - t)f''(t) dt.$$
This is a modification of exercise 6.6.4 from Advanced Calculus by Fitzpatrick. I have seen that this question has been asked here: Proving $f(x) = f(0) + f'(0)x + \int_0^x (x-t) f''(t) dt$ for all x. However, there didn't seem to be a suitable answer.
Here is my attempt at the problem.
Since $f$ has a continuous second derivative, then the first derivative is also continuous. Therefore, by the first fundamental theorem of calculus, we have that
$$f(x) = f(a) + \int_a^x f'(t)dt.$$
Expanding out the right-hand side of the above using integration by parts, we see that
$$f(x) = f(a) + f'(t)t - \int_a^x tf''(t) dt.$$
This is where I am confused.
 A: Let $u(t) = f'(t)$ and let $v(t) = t-x$ (don't be confused by the fact that there's an $x$ in the definition of $v(t)$; right now we are keeping $x$ fixed and varying $t$). Then, we apply integration by parts:
\begin{align}
\int_a^x f'(t) \cdot 1 \, dt &= \int_a^x u(t) \cdot v'(t) \, dt \\
&= u(t) \cdot v(t) \bigg\rvert_a^x - \int_a^x u'(t) \cdot v(t) \, dt \\
&= \left(f'(x) \cdot 0 - f'(a) \cdot (a-x) \right) - \int_a^x f''(t) \cdot (t-x) \, dt \\
&= (x-a) f'(a) + \int_a^x (x-t) f''(t) \, dt
\end{align}
Hence,
\begin{align}
f(x) &= f(a) + \int_a^x f'(t) \, dt \\
&= f(a) + (x-a) f'(a) + \int_a^x (x-t) f''(t) \, dt
\end{align}
A: You did a mistake in the integration by parts
$$
\int_a^x f'(t) dt = \left[t f'(t) \right]_a^x - \int_a^x tf''(t) dt = \\
xf'(x) - af'(a) - \int_a^x tf''(t) dt = \\
(x-a)f'(a) + (f'(x) - f'(a))x - \int_a^x tf''(t) dt = \\
(x-a)f'(a) + x \int_a^x f''(t) dt - \int_a^x tf''(t) dt = \\
(x-a)f'(a) + \int_a^x (x-t) f''(t) dt
$$
A: Integration by parts is not necessary.
Put
$$g(x)=f(x)-f(a)-(x-a)f'(a)$$
and
$$h(x)=\int_a^x(x-t)f''(t)dt$$
and
$$k(x)=g(x)-h(x)$$
Then $k'(x)=0$ for all $x$, hence $k(x)$ is a constant. In particular, $k(x)=k(a)=0$.
Hence $g(x)=h(x)$, whence the desired identity follows.
A: Just note that applying partial integration to the integral gives
\begin{eqnarray*} \int_a^x(x - t)f''(t) dt
& = & \left[(x-t)f'(t) \right]_a^x +\int_a^xf'(t) dt\\
& = & -(x-a)f'(a) + f(x) - f(a)
\end{eqnarray*}
Now, solve for $f(x)$.
