Update: I have realised that I did not really understand what I was asking, so I have significantly updated my question, and have provided my own answer below.
$ f(x_1, ..., x_n) $ is a function explicitly dependent on functions $x_i$. The total derivative with respect to the independent variable $y$ (that $f$ depends on implicitly through the intermediate variables $x_i$) is $ \frac{d f}{d y} = \sum_i\frac{\partial f}{\partial x_i} \frac{\partial x_i}{\partial y}$. It seems that one could perform this derivative in two different ways:
- $\sum_i \left.\frac{\partial f}{\partial x_i}\right|_{x_{j\neq i}}\frac{\partial x_i}{\partial y}$
- $\sum_i \frac{\partial f}{\partial x_i}\left.\frac{\partial x_i}{\partial y}\right|_{x_{j\neq i}}$
where $\left.\frac{\partial f}{\partial x_i}\right|_{x_{j\neq i}}$ means the partial derivative of $f$ with respect to $x_i$ while holding all of the other $x_{j \neq i}$ fixed.
For example, let's say $f = 2x_1 + 3x_2$, $x_1 = 4y + 5x_2$, $x_2 = 6y$. Then:
$\left.\frac{\partial f}{\partial x_1}\right|_{x_2} = 2$
$\left.\frac{\partial f}{\partial x_2}\right|_{x_1} = 3$
$\left.\frac{\partial x_1}{\partial y}\right|_{x_2} = 4$
$\left.\frac{\partial x_2}{\partial y}\right|_{x_1} = 6$
$\frac{\partial f}{\partial x_1} = 2 $
$\frac{\partial f}{\partial x_2} = 3 + 2*5 = 13$
$\frac{\partial x_1}{\partial y} = 4 + 5*6 = 34$
$\frac{\partial x_2}{\partial y} = 6 $
Approach 1 above gives $2*34 + 3*6 = 86$.
Approach 2 above gives $2*4 + 13*6 = 86$.
Are both of these approaches always valid?
I think it is easiest to understand this by visualising a dependency branch diagram. $f$ depends on the $x_i$s, so it is connected to all of them (I'll call these the first branches), then there are dependencies between the $x_i$s, so some of those are connected (second branches), and then the $x_i$s also depend on $y$ (third branches). The difference between approaches 1 and 2 is whether the second branches are included in the first factor $\left(\frac{\partial f}{\partial x_i}\right)$ or the second $\left(\frac{\partial x_i}{\partial y}\right)$. It doesn't matter which they are included in, as long as they are included once and only once.