 A constrained optimization problem as the one stated above usually suggests a Lagrangian expression, specifically 
where the formula_16 compare to the Lagrange multiplier in a static optimization problem but are now, as noted above, a function of time.Proceeding with a Legendre transformation, the last term on the right-hand side can be rewritten using integration by parts, such that
which can be substituted back into the Lagrangian expression to give
To derive the first-order conditions for an optimum, assume that the solution has been found and the Lagrangian is maximized.Then any change to formula_10 or formula_6 must cause the value of the Lagrangian to decline.