$\max_{x(t),u(t)}\int _0^Te^{-t}f(x(t),u(t))dt$,
st derivative $x_t=g(t,x(t),u(t))$. Prove that $H$ is constant.
My try2:
consider the Hamiltonian $$ H(x(t), u(t)) = e^{-t}f(x(t), u(t)) + \lambda(t) g(x(t), u(t)). $$ Then: $$ \begin{align*} \frac{d}{dt} H(x(t), u(t)) &= (e^{-t}f_x + \lambda g_x)\dot x + \underbrace{(H_u)}_{=0} \dot u + g(x(t), u(t)) \dot \lambda,\\ &= \dot x(e^{-t}f_x + \lambda g_x) + g(x(t), u(t)) \underbrace{(-e^{-t}f_x - \lambda g_x)}_{=\dot \lambda_t},\\ &= \underbrace{(\dot x - g(x(t), u(t))}_{=0} (e^{-t}f_x + \lambda g_x),\\ &= 0 \end{align*} $$
References: Chiang (1992), https://people.stfx.ca/tleo/advmacrolec3.pdf