Applying the Rayleigh Ritz variational method and the Galerkin method to a simple problem using a global trial function is shown to give the same solution.
The solutions are compared to the exact solution. In this example, one can determine that the exact solution was reached by increasing the order of the polynomial that is used as the trial function, until the solution returned by Rayleigh Ritz or Galerkin method no longer changes.
This however does not guarantee that the exact solution can be found using this approach in all cases.