I am reading "Optimal Control Theory" from Kirk. When solving the optimal control problem, there is defined The Hamiltonian $H(x(t),u(t),p(t), t)$ as $g(x(t), u(t), t) + p [a(x(t), u(t), t]$ where $x(t)$ is the state, $p(t)$ is the costate, $u(t)$ is the control input, $a(x(t), u(t), t)$ describes the system dynamics $\dot x = a(x(t),u(t),t)$, and $g(x(t), u(t), t)$ is the function whose integral is the performance measure. But what if the performance measure contains the first derivative? For example, when I am paying speed penalty?
I am rather confused, because in the book so far, $\dot x$ has always been a part of $g(x,\dot x, u, t)$.