Why does Einstein's photoelectric effect equation assume $\text{KE}_{max}=\frac{1}{2}mv_{max}^2$ The derivation of Einstein's photoelectric equation is shown as such in the textbook I am currently using:

The work function $W$ of a metal is related to its threshold frequency $f_o$ by:
$$W=hf_o$$
If frequency $f$ of incident radiation is greater than $f_o$ then the energy of the photon off radiation:
$$hf>hf_o$$
And the emitted photoelectrons would have a:
$$\text{maximum kinetic energy}=hf-hf_o$$
$$E_{max}=\frac{1}{2}m(v_{max})^2=hf-W$$
$$=h(f-f_o)$$

However, I do not understand how the maximum kinetic energy could be $\text{KE}_{max}=\frac{1}{2}mv_{max}^2$?
As energy is obviously required by the electron to reach the surface of the metal and any residual energy left greater than that of the work function would then be used into kinetic energy and the electron would not reach maximum velocity.
 A: The work function is the minimum thermodynamic work (i.e., energy) needed to remove an electron from a solid to a point in the vacuum immediately outside the solid surface. Here "immediately" means that the final electron position is far from the surface on the atomic scale, but still too close to the solid to be influenced by ambient electric fields in the vacuum.
The work function is not a characteristic of bulk material, but rather a property of the surface of the material (depending on crystal face and contamination).
The work function depends on the configurations of atoms at the surface of the material. For example, on polycrystalline silver, the work function is $4.26$ eV, but on silver crystals, it varies for different crystal faces as $(100)$ face: $4.64$ eV, $(110)$ face: $4.52$ eV, $(111)$ face: $4.74$ eV. Ranges for typical surfaces are shown in the table below.

The text uses the minimum value of the work function and that corresponds to a maximum value of kinetic energy. So you can write if want to
$$T_{max}=h\nu-\phi_{min}$$
