I've just wondered where the formula $E_{pot} = mgh$ you learn at school comes from so I've tried to work it out - is my reasoning correct? The change in energy is given by
$$\Delta E=\int_{e}^{e+h}G\frac{mM}{r^2}dr,$$ where $e$ is the radius of earth. The integral is equal to $$\Delta E=\left [-G\frac{mM}{r} \right ]_e^{e+h}.$$ Because $GM=ar^2$, $$\Delta E = \frac{mae^2}{e}-\frac{ma(e+h)^2}{e+h}.$$ On earth the acceleration is $g$ and because of that $$\Delta E=mge-mge+mgh=mgh.$$
But I've heard that $mgh$ is only an approximation if the change in height is approximatly constant - so why does my derivation equal to $mgh$ no matter how big the change in height is? Do I need to integrate with respect to acceleration from the start?