Generalized discrete variable approximation in quantum mechanics