A good illustration of this is the light clock. Imagine you have two observers, one sat on a train with a light clock next to them (see image below) and the other sat watching the train.

Doing a little bit of Pythagoras on the relativistic case we see:
$$ L^{2} = d^{2} + (\frac{u*t_{r}}{2} )^{2} $$
Where $t_{r}$ is the time it takes the light to move from the bottom mirror, to the top and back again.
We can also see that $L = \frac{c t_{r}}{2}$ since this is the time it has taken light to traverse this path and, from the stationary observer's case we see $d = \frac{c t_{c}}{2}$ where $t_{c}$ is the time it takes for light to go from bottom to top and back again in the classical case.
If we substitute these into our equation we get:
$$ (\frac{c t_{r}}{2})^{2} = (\frac{c t_{c}}{2})^{2} + (\frac{u*t_{r}}{2} )^{2}$$
Dividing through by $\frac{c t_{r}}{2}$ gives:
$$ 1 = (\frac{t_{c}}{t_{r}})^{2} + (\frac{u}{c})^{2} $$
and if we rearrange this to get an equation for $t_{c}$ in terms of $t_{r}$ we get:
$$ t_{c} = t_{r} \sqrt{1-(\frac{u}{c})^{2}} $$
Where $\sqrt{1-(\frac{u}{c})^{2}} $ is often denoted by $\frac{1}{\gamma}$, this factor is your $f(S)$ proposed in your question.