Galerkin Approximation of the Generalized Hamilton-Jacobi Equation