Deriving the paraxial power of a curved surface by using Fermat's principle I was reading slide 2 of this lecture, which derives the paraxial power of a curved surface by using Fermat's principle. The author proceeded as follows.
Consider a curved surface between two refractive indices as follows:

The $z$ coordinate of the surface is $r^2 + z^2 = R^2$, and so
$$\begin{align} z = \sqrt{R^2 - r^2} &\approx R \left( 1 - \dfrac{1}{2} \dfrac{r^2}{R^2} \right) \ \ \text{(By the binomial approximation.)} \\ &= R - \dfrac{1}{2} \dfrac{r^2}{R} \end{align}$$
Therefore, the optical path length along $z$ at some height $r$ is
$$\begin{align} S = nL + n'L' &= n\left( \dfrac{1}{2} \dfrac{r^2}{R} \right) + n' \left( d - \dfrac{1}{2} \dfrac{r^2}{R} \right) \\ &=  -(n' - n) \left( \dfrac{1}{2} \dfrac{r^2}{R} \right) + n' d \\ &\equiv -\dfrac{r^2}{2f} \ \ \text{(Set equal to the definition of optical path length for a thin lens.)}, \end{align}$$
where it is said that $d$ is some arbitrary thickness measured from the origin.

Therefore, we have that the paraxial power of a curved surface is
$$\phi = \dfrac{1}{R} (n' - n) = c(n' - n) \ \ \text{(Since $\dfrac{1}{f} \equiv \phi = -\dfrac{n}{t} + \dfrac{n'}{t'}$.)}$$
Why do we have $L = \dfrac{1}{2} \dfrac{r^2}{R}$ instead of $R - \dfrac{1}{2} \dfrac{r^2}{R}$, since that is what we found and used for $L'$? What happened to the $R$ and negative sign here? I suspect that this has something to do with sign convention and the direction that the ray is travelling, but I'm not sure.
I would greatly appreciate it if people could please take the time to clarify this.
 A: 
So here I have used the same image you posted in the question and just labelled and edited it a bit.
The $z$ co-ordinate which you found out to be $\sqrt {R^2-r^2}$, is actually the length $OB$, which you can see in the image.
So now here we should analyse the path of light between $C$ and $A$. And since the rays are paraxial, we will assume that the light rays are, more or less, horizontal.
So the distance that the light rays travelled in medium with refractive index $n$ is equal to the length of the segment $AB$. (Note that we are only considering the path of light between $C$ and $A$). But,
$$OA=R \:\: \text {and} \: \: OB =z \Rightarrow AB=OA-OB=R-z= \frac{1}{2} \frac{r^2}{R} =L $$
Also the distance travelled by the light in $n'$ is the length of the segment $CB =L'=AC-AB$
Now in the question itself, it is given that $AC = d$, and we also know that $AB=L= \frac{1}{2} \frac{r^2}{R}$
So using this, we get
 $$CB=L'=d- \frac{1}{2} \frac{r^2}{R}$$
And thus the equation 
$$S=nL+n'L'=n \left( \frac{1}{2} \frac{r^2}{R}\right) +n' \left(d- \frac{1}{2} \frac{r^2}{R} \right) $$
is justified to be true.
I assume that you don't have any problem with the other stuff following this equation, which you posted in your question.
