My textbook, Fundamentals of Photonics, 3rd edition, by Teich and Saleh, says the following:
Fermat's Principle. Optical rays travelling between two points, $A$ and $B$, follow a path such that the time of travel (or the optical pathlength) between the two points is an extremum relative to neighboring paths. This is expressed mathematically as
$$\delta \int_A^B n(\mathbf{r}) \ ds = 0, \tag{1.1-2}$$
where the symbol $\delta$, which is read "the variation of," signifies that the optical pathlength is either minimized or maximized, or is a point of inflection. ...
This probably doubles as a mathematics question, but I'm going to ask it here anyway.
How does the fact that the optical rays follow a path such that the time of travel (optical pathlength) between two points is an extremum relative to neighboring paths imply the result $\delta \int_A^B n(\mathbf{r}) \ ds = 0$? I'm struggling to develop an intuition for why/how the "variation of" optical pathlength would be $0$ in this case.
I would greatly appreciate it if people could please take the time to clarify this.