Let $u(t)$ be a solution of the ODE $u''(t)+tu'(t) + u(t) = f(t)$ on the time interval $[0,T]$, with fixed initial data $u(0)=u_0$, $u'(0) = u_1$ where $f(t)$ is a control function. Find $f(T), f'(T)$, and the ODE satisfied by $f$ when $(u,f)$ is a critical point of the cost functional $$C(U,f) = u^2(T) + \int_{0}^{T}f^2(t)dt.$$
How can we find $f(T)$? $f'(T)$? How do we find the ODE for the critical point of the cost functional?