The above starts with S=1 + a^2 + a^3 + ... + a^n.

I understand how the first part (dealing with S) works but I dont understand how it relates to the expression below the paragraph.

$\displaystyle 1-a^{n+1}$ in the second expression after the paragraph must correspond with $\displaystyle 1- (1+\frac{r}{n})^{-nt}$ and $\displaystyle (1-a)$ must correspond to $\displaystyle (1-(1+\frac{r}{n})^{-1})$

but im not sure what role the first term: $\displaystyle x(1+\frac{r}{n})^{-1}$ plays or how we get to the third expression at the bottom.