Partial derivatives with respect to two functions while keeping one of them constant I have a function of $f(x_1, x_2)$, and two other functions of $g_1(x_1, x_2)$ and $g_2(x_1, x_2)$ in such a way that the original function can be written as $ f(g_1, g_2) $.
Now I need to fine partial derivative of $f$ with respect to $g_1$ or $g_2$ while keeping the other constant. That is
$$
\Big( \dfrac{\partial f}{\partial g_1} \Big)_{g_2 = const}
$$
and
$$
\Big( \dfrac{\partial f}{\partial g_2} \Big)_{g_1 = const}
$$
What is the correct formula to do this?
 A: This is probably not the most rigorous or direct way of doing it, but it should explain what's going on:
By the chain rule, we can write 
$$ \begin{align}
\mathrm{d}f &= f_x\ \mathrm{d}x + f_y\ \mathrm{d}y \\
\mathrm{d}g_1 &= g_{1x}\ \mathrm{d}x + g_{1y}\ \mathrm{d}y \\
\mathrm{d}g_2 &= g_{2x}\ \mathrm{d}x + g_{2y}\ \mathrm{d}y \\
\end{align} $$
Let us think about $(\partial f/\partial g_1)_{g_2}$. The condition $g_2 = \text{constant}$ means that we are confined to move along a contour of $g_2$, so let us first work out what those contours are, and then work out the rates of change of $f$ and $g_1$ if we move along such a contour.
Since $g_2 = \text{constant}$ along a contour, we must have 
$$ g_{2x}\ \mathrm{d}x + g_{2y}\ \mathrm{d}y = 0 $$
and so 
$$ \mathrm{d}y = - \frac{g_{2x}}{g_{2y}}\ \mathrm{d}x $$
on contours of $g_2$ (but see Note 1). The contours are therefore described by the differential equation
$$ \frac{\mathrm{d}y}{\mathrm{d}x} = - \frac{g_{2x}}{g_{2y}}. $$
Now we have a relationship between $\mathrm{d}y$ and $\mathrm{d}x$. We shall substitute these into the expressions for $\mathrm{d}f$ and $\mathrm{d}g_1$ to work out the rates of change of $f$ and $g_1$ along the contours.
For $f$, we have
$$ \mathrm{d}f = \left(f_x - \frac{g_{2x}}{g_{2y}} f_y \right)\ \mathrm{d}x $$
and a corresponding equation for $\mathrm{d}g_1$. Dividing the two (see Note 2) then gives the desired expression:
$$ \left(\frac{\partial f}{\partial g_1}\right)_{g_2} = 
\frac{ f_x g_{2y} - f_y g_{2x} }{ g_{1x} g_{2y} - g_{1y} g_{2x} }, $$
or, in terms of 'Jacobian determinants':
$$ \left(\frac{\partial f}{\partial g_1}\right)_{g_2} = 
\frac{ \partial(f,g_2)/\partial(x,y) }{ \partial(g_1,g_2)/\partial(x,y) }. $$
Notes


*

*If $g_{2y}=0$, then we can proceed instead by writing $\mathrm{d}x$ in terms of $\mathrm{d}y$ instead, and proceed accordingly to get the same result. 
If both $g_{2x}$ and $g_{2y}$ are zero at the same point, then $g_2$ is stationary there, and $(\partial f/\partial g_1)_{g_2}$ is not defined at that point.  

*The partial derivative $(\partial f/\partial g_1)_{g_2}$ is undefined at points where $\partial(g_1,g_2)/\partial(x,y) = 0$. At such points, the gradients of $g_1$ and $g_2$ are not linearly dependent, which means that the contour of $g_2$ is also a contour of $g_1$; the rate of change of $g_1$ is therefore zero there. 
