Mathematical Modeling of Electron Optics