Quantification of stability of analytic continuation with applications to electromagnetic theory