Error Estimates for Approximate Optimization by the Extended Ritz Method