Three-dimensional inverse problem of geometrical optics: A mathematical comparison between Fermat's principle and the eikonal equation