Error Estimate of Ritz and Galerkin Methods