An efficient method for the analysis of electron waveguides