To avoid the division by 0, you need to take the limit as y approaches 0, rather than just substituting 0.
If you examine your expression, you have arccos(x/sqrt(x^2+y^2)) . Differentiate with respect to x and you get something that has a denominator of sqrt(-x^2/(x^2+y^2)+1) . As y approaches 0, this approaches sqrt(-x^2/x^2 + 1) which approaches sqrt(-1+1) which is sqrt(0) which is 0. Therefore you would have a division by 0 if you consider the denominator in isolation. If you take the limit of the numerator and denominator, the numerator approaches 0 faster than the denominator approaches 0, so the limit approaches 0 -- but the instantaneous evaluation has a division by 0.
