$g(x,y,z(x,y))$ - how to compute $\frac{\partial g}{\partial x}$ using chain rule? I was thinking about this: 
Let's say $g(x,y,z)$ is some function of $x,y,z$, but $z$ is a function of $x,y$. How would you compute $\frac{\partial g}{\partial x}$?
Here's my thoughts intuitively but it doesn't seem to make sense mathematically.
I would think that this would be true:
$$\frac{\partial g}{\partial x} = \frac{\partial g}{\partial x} + \frac{\partial g}{\partial z} \frac{\partial z}{\partial x}$$
This is what I think because $g$ will be changed by $x$ directly and $z$ will change because of $x$ also, which results in an additional change to $g$. 
But this would imply:
$$0 = \frac{\partial g}{\partial z} \frac{\partial z}{\partial x}$$
So then one of these terms has to be zero. I don't believe this could be correct but I can't figure out the flaw in my reasoning.
 A: Partial derivative notation is terrible; this example is one of the reasons why. In the equation
$$\frac{\partial g}{\partial x} = \frac{\partial g}{\partial x} + \frac{\partial g}{\partial z} \frac{\partial z}{\partial x}$$
the appearance of $\frac{\partial g}{\partial x}$ on the left hand side means something completely different from the appearance of $\frac{\partial g}{\partial x}$ on the right hand side.
When working with functions (in my example, $f$ is a univariate function), I find the best practice is:


*

*Don't write $f$ in a place where a scalar is expected.

*Don't write $f(x)$ in a place where a function is expected

*Write $f'$ for the derivative of $f$. With a function, like your $g$, that has multiple places, I like the notation $g_1$, $g_2$, and $g_3$ for the derivatives in the three places.


Then, the correct formula is
$$ \frac{\partial g(x, y, z(x,y))}{\partial x}
= g_1(x, y, z(x,y)) + g_3(x, y, z(x,y)) z_1(x, y) $$

That said, I prefer to compute with differentials than with partial derivatives when possible. I will also make the following change, since it's probably what you actually want:


*

*$z$ is not a function, but a scalar, related to $x$ and $y$ through an auxiliary function $z = h(x,y)$


Then, the differential is given by
$$ \mathrm{d}g(x,y,z) = g_1(x,y,z) \mathrm{d}x + 
g_2(x,y,z) \mathrm{d}y + g_3(x,y,z) \mathrm{d}z $$
(note that this equation is true even if $z$ is independent from $x$ and $y$)
Furthermore, we have
$$ \mathrm{d}z = h_1(x,y) \mathrm{d}x + h_2(x,y) \mathrm{d}y$$
which we can substitute into the above.
The premise asks for the derivative under the restriction that $y$ is held constant — that is, $\mathrm{d}y = 0$. Under that restriction we have
$$ \mathrm{d}g(x,y,z) = \left( g_1(x,y,z) + 
g_3(x,y,z) h_1(x,y) \right) \mathrm{d}x $$
A: Really you have:
$$g(u(x,y),v(x,y),z(x,y))$$
where $u(x,y)=x$, $v(x,y)=y$. So then:
$$g_x=g_u u_x+g_v v_x+g_z z_x$$
Simplifying:
$$g_x(x,y,z)=g_u(x,y,z)+g_z(x,y,z)z_x(x,y)$$
