Let $S : [a,b] \times \mathbb{R}^n \to \mathbb{R}$ be a $C^2$ solution of the Hamilton–Jacobi equation $S_x + H(x, y, \nabla_y S) = 0$. Let $(y_0, p_0)$ be any initial data with $p_0 = \nabla_y S(a, y_0)$, and let $(y(x), p(x))$ be the solution of Hamilton's equations
\begin{align*}
y' &= \nabla_p H(x, y, p), \\
p' &= -\nabla_y H(x, y, p)
\end{align*}
with initial conditions $(y(a), p(a)) = (y_0, p_0)$. Then $p(x) = \nabla_y S(x, y(x))$ for all $x$ in the interval of existence, and $S(x, y(x)) = S(a, y_0) + \int_a^x L(t, y(t), y'(t))\, dt$.