Differentiate the constraint equation to get the relationship between $\dot{x}$ and $\dot{u}$ for first-order necessary condition
Lagrangian multiplier: $\lambda$ is the costate variable. It’s to transform the constrained optimization problem to unconstrained optimization problem.
$dL = 0$ equals to $dH = 0$. With $dH = 0$, we can get the first-order necessary condition and solve the state.
General optimization setting.
Sufficient condition in practice: express $dy$ in terms of $du$, then substitute $du$ into $dL = 0$ to get the second-order necessary condition to get a less strict condition.
Inequality constraints
Based on the lecture notes by Dr. Marin Kobilarov on “Applied Optimal Control (2021 Fall) at Johns Hopkins University