Derivative of a function of the form $f=f(x,g(x))$ Consider a function of the following form $f=f(x,g(x))$. For the derivative of this function, we do the following.
$$
\frac{df}{dx} = \frac{df}{dx} \bigg\rvert_{g}+\frac{df}{dg} \frac{dg}{dx}
$$
I have the following question about the above equation.

*

*Since $g$ itself is a function of $x$, does it even make sense to say "$f$ is a function of $x$ and $g$"?

*Does the first term of the equation read "derivative of $f$ with respect to $x$ at a fixed $g$"? If so, how does this make sense since if $x$ is changed, $g$ also changes and the derivative is no longer calculated at a fixed $g$.

Please let me know if you need me to make myself more clearer. Thank you for answering.
 A: There is an abuse of notation here, insofar as the letter $x$ is used for various purposes. In reality you have a function
$$(x,y)\mapsto f(x,y)$$
of two variables, giving, say, the temperature at the point $(x,y)$ in the plane. Furthermore you have a path
$$\gamma:\qquad t\mapsto \left\{\eqalign{x(t)&:=t \cr y(t)&:=g(t)\cr}\right.$$
in the plane. Now you want to know to deal with the temperature felt at the moving point, as a function of $t$. This is the function
$$\phi(t):=f\bigl(x(t),y(t)\bigr)\qquad\bigl(\> =f(t,g(t))\ \bigr)\ .$$
The chain rule gives
$$\eqalign{\phi'(t)&=f_x\bigl(x(t),y(t)\bigr)x'(t)+f_y\bigl(x(t),y(t)\bigr)y'(t)\cr  &=f_x\bigl(t,g(t)\bigr)\cdot1+f_y(t,g(t)\bigr)g'(t)\ .\cr}$$
A: I would handle all this differently.
Let a function $f(x,y)$ of two arguments. We have the partial derivatives
$$f_x=\frac{\partial f}{\partial x},f_y=\frac{\partial f}{\partial y},$$ which are themselves functions of two variables.
Now for some $g(x)$, define $h(x):=f(x,g(x))$, and by using differentials,
$$\frac{dh}{dx}=f_x\frac{dx}{dx}+f_y\frac{dg}{dx}=f_x+f_yg'.$$
More precisely,
$$\frac{dh(x)}{dx}=f_x(x,g(x))+f_y(x,g(x))g'(x).$$

*

*$h$ is a function of $x$.


*the partial derivatives are taken formally, with the other argument held fixed.
The variation of $h$ has two terms: a direct one due to the variation of $x$ as the first argument of $f$, and an indirect one due to the variation of the second argument via $g$.
A: Tl;dr:
$f(x,y)$ is a surface.
Substituting $y(x)$ i.e: y as a function of x means that we are moving on some curve in the input plane, corresponding to this curve we trace out a curved path on the surface.
So actually this function is now dependent on only one variable $x$, the rate of change as we 'change' $x$ is equal to the rate of change of the function if x and y were independent plus the rate of of change of the function with y if x and y were independent multiplied by the rate of change amplification which comes from the $y$ being parameterized by $x$
i.e:
$$ \frac{df}{dx} = \frac{ \partial f}{\partial x}  + \frac{ \partial f}{\partial y} \frac{dy}{dx}$$
