拉格朗日量
\[\begin{aligned}
\mathcal L &= T(q, \dot q) - V(q) \\
\end{aligned}
\tag{1}\]
\[\begin{aligned}
J(q, \dot q) &= \int_{t_1}^{t_2} \mathcal L(q, \dot q) \, dt \\
\end{aligned}
\tag{2}\]
\[\begin{aligned}
x & \triangleq [q^T, \dot q^T]^T \\
\dot q = \begin{bmatrix}
0 & I \\
\end{bmatrix} x \\
\end{aligned}
\tag{3}\]
\[\begin{aligned}
J_a(x) &= \int_{t_1}^{t_2} \mathcal L(x) + p^T (A x - B\dot x) \, dt \\
A & \triangleq \begin{bmatrix}
0 & I \\
\end{bmatrix}_{n \times 2n} \\
B & \triangleq \begin{bmatrix}
I & 0 \\
\end{bmatrix}_{n \times 2n} \\
\end{aligned}
\tag{4}\]
\[\begin{aligned}
\mathcal{H} = \mathcal L + p^T A x \\
\end{aligned}
\tag{5}\]
\[\begin{aligned}
\dot p &= -\frac{\partial \mathcal H}{\partial x} \\
&= -\frac{\partial \mathcal L}{\partial x} - A^T p \\
\begin{bmatrix}
\dot p_1 \\
\dot p_2
\end{bmatrix}&= -\begin{bmatrix}
\frac{\partial \mathcal L}{\partial q} \\
\frac{\partial \mathcal L}{\partial \dot q}
\end{bmatrix} -
\begin{bmatrix}
0 \\ p_1
\end{bmatrix} \\
\end{aligned}
\tag{6}\]