Need an explanation for
$$\lim_{x\to y} \cot(g(y)-g(x))-g'(y)^{-1}\cot(y-x)=\frac{g''(y)}{2g'(y)^2}$$
This question does not have any additional conditions, clearly the functions $g$ is from $C^2$. The problem is, I am getting $\frac{g''(y)}{g'(y)^2}$ (using mean value theorem), but while I solve by substituting $g$ with some other functions, I get the answer of the form $\frac{g''(y)}{2g'(y)^2}$ (I used mathematica). What I don't understand is how that $\frac{1}{2}$ came over there. Here is my explanation: $\cot(g(y)-g(x))-g'(y)^{-1}\cot(y-x)=\frac{1}{y-x}\left(\frac{y-x}{g(y)-g(x)}(g(y)-g(x))\cot(g(y)-g(x))-g'(y)^{-1}(y-x)\cot(y-x)\right)$
as $x\to y$, $(g(y)-g(x))\cot(g(y)-g(x))$ and $(y-x)\cot(y-x)$ tends to 1. Hence, the total limit must tend to $\frac{d}{dy}\frac{1}{g'(y)}$. If there is any mistake in my explanation kindly point it out.
If you set $z=x-y$, $A=g'(y)$ and $B=\frac{1}{2}g''(y)$, the limit can be rewritten, using $$ g(y+z)=g(y)+g'(y)z+\frac{g''(y)}{2}z^2+o(z^2) $$ as $$ \lim_{z\to0} \frac{\tan(Az+Bz^2+o(z^2))-A\tan z} {A\tan z\tan(Az+o(z))}= \lim_{z\to0} \frac{Az+Bz^2-Az+o(z^2)}{A^2z^2+o(z^2)}=\frac{B}{A^2}=\frac{g''(y)}{2g'(y)^2} $$