Perturbation characteristic functions and their application to electron optics