I have a question on SIFT
Horizontal and vertical gradients are computed by taking neighbor pixel differences:

$$g_{x}=L(x+1,y)-L(x-1,y)\\g_{y}=L(x,y+1)-L(x,y-1)$$

Gradient magnitude is computed the same way as in your formula:

$$m(x,y)=\sqrt{g_x^2+g_y^{2}}$$

Replacing $g_{x}$ and $g_{y}$ with above will give you the original formula.

Gradients are usually computed by forward or central difference formula, but I think in this case the above is still accurate enough since the image $L$ is smoothed.