I shall explain how the Hamilton-Jacobi equation can be derived from
a second order linear PDE. Then I shall present a modification of this
setting giving rise to a similar equation on a certain principal bundle
with structure group $U(1)$ or $\R$. One can generalize this in several
aspects, one of them is allowing the structure group to be arbitrary.