# How does one derive the elasticity of substitution with implicit functions?

I would like to derive the elasticity of substitution. I'm aware that such a thread with a very straightforward explanation already exists, but my case is slightly different and I'm not sure how to differentiate the functions involved.

But let me first introduce you to my problem. I have to derive the elasticity of substitution $$\sigma = \frac{f_1 f_2(f_1z_1+f_2z_2)}{z_1z_2[2f_{1,2}f_1f_2-f_{11}(f_2)^2-f_{22}(f_1)^2]}$$ where I have the following production function $y^0 - f(z_1,rz_1)=0$ for which $r$ is defined the following: $r=\frac{z_2}{z_1}$.

As I have already mentioned this problem is already perfectly solved in this thread: How does one derive the elasticity of substitution?

But now comes the clue in my specification, where I do not now how to proceed: I have to express $z_1$ as function of $r$, such that $z_1=g(r)$. The marginal rate of substitution can thus be expressed as follows $$MRTS_{21}=\frac{f_1(g(r),rg(r))}{f_2(g(r),rg(r))}$$ How can I derive the differential of $f(g(r),rg(r))$, which is the first step in the derivation of the elasticity of substitution. I somehow should use the theorem of implicit functions, but I'm not sure how..

I hope someone can explain this differential to me!

Cheers