Let $f(x,y) = x + x^2 + y$, we have $f_x(x,y) = 1 + 2x$.
Let $u = x^2$ and write $f(x,y,u) = x+ u +y$. When applying the chain rule, $f_x(x,y,u) = f_u(x,y,u)(du/dx) + f_y(x,y,u) (dy/dx) + f_x(x,y,u) (dx/dx)$. It then becomes tempting to cancel the LHS with the last term of RHS to get $f_u(x,y,u)(du/dx) + f_y(x,y,u)(dy/dx) = 0$. The problem is that the RHS $f_x(x,y,u)$ means to keep $y,u$ as fixed constants while the LHS has $u = u(x)$.
To tackle this problem, I write $f_x(x,y,u) = f_u(x,y,u)|_{x,y}(du/dx) + f_y(x,y,u)|_{x,u} (dy/dx) + f_x(x,y,u)|_{y,u} (dx/dx)$ to note which variables are fixed for each partial derivative. My question: is this correct? And is there anything else I need to watch out for when applying the chain rule using this formula?
You denote two different functions by the same symbol $f$, the two-variable function $f : \mathbb R^2 \to \mathbb R , f(x,y) = x + x^2 + y$, and the three-variable function $f : \mathbb R^3 \to \mathbb R , f(x,y,u) = x+ u +y$. This must not be done, write e.g. $F : \mathbb R^3 \to \mathbb R ,F(x,y,u) = x + y + u$.
Define $g : \mathbb R^2 \to \mathbb R^3, g(x,y) = (x,y,x^2)$. Then $f = F \circ g$. We can now apply the chain rule of multivariable analysis. Let us do it via the Jacobians of $F$ and $g$. We have
$$JF(x_0,y_0,u_0) = \left( \begin{array}{rrr} \frac{\partial F}{\partial x}(x_0,y_0,u_0)\phantom{x} \frac{\partial F}{\partial y} (x_0,y_0,u_0) \phantom{x} \frac{\partial F}{\partial u}(x_0,y_0,u_0)\\ \end{array}\right) = \left( \begin{array}{rrr} 1 \phantom{x} 1 \phantom{x} 1 \\ \end{array}\right),$$ $$Jg(x_0,y_0) = \left( \begin{array}{rrr} \frac{\partial g_1}{\partial x}(x_0,y_0) & \frac{\partial g_1}{\partial y}(x_0,y_0) \\ \frac{\partial g_2}{\partial x}(x_0,y_0) & \frac{\partial g_2}{\partial y}(x_0,y_0) \\ \frac{\partial g_3}{\partial x}(x_0,y_0) & \frac{\partial g_3}{\partial y}(x_0,y_0) \\ \end{array}\right) = \left( \begin{array}{rrr} 1 & 0 \\ 0 & 1 \\ 2x_0 & 0 \\ \end{array}\right)$$ where $g_1(x,y) = x , g_2(x,y) = y, g_3(x,y) = x^2$ are the component functions of $g$. It seems that you write $\frac{\partial g_1}{\partial x} = \frac{dx}{d x}$, $\frac{\partial g_2}{\partial x} = \frac{dy}{d x}$ etc. which is not correct. You must again distinguish the two-variable functions $g_i$ from the one-variable functions $x, y, u$. Moreover, the expression $\frac{dy}{d x}$ only makes sense if $y$ is a function of $x$, and that is not true.
The chain rule says that (where $\cdot$ is matrix mutliplicaton) $$Jf(x_0,y_0) = JF(g(x_0,y_0)) \cdot Jg(x_0,y_0) = \\ = (1 +2x_0 \phantom{x} 1) = \left( \begin{array}{rrr} \frac{\partial f}{\partial x}(x_0,y_0)\phantom{x} \frac{\partial f}{\partial y} (x_0,y_0)\\ \end{array}\right)$$ which is no surprise. Omitting the arguments $(x_0,y_0)$ and $g(x_0,y_0) = (x_0,y_0,x_0^2)$ we have on the abstract level $$\left( \begin{array}{rrr}\frac{\partial f}{\partial x} \phantom {xxx} \frac{\partial f}{\partial y}\\ \end{array}\right) = Jf = JF \cdot Jg \\= \left( \begin{array}{rrr}\frac{\partial F}{\partial x}\frac{\partial g_1}{\partial x} +\frac{\partial F}{\partial y}\frac{\partial g_2}{\partial x} + \frac{\partial F}{\partial u}\frac{\partial g_3}{\partial x} \phantom {xxx} \frac{\partial F}{\partial x}\frac{\partial g_1}{\partial y} +\frac{\partial F}{\partial y}\frac{\partial g_2}{\partial y} + \frac{\partial F}{\partial u}\frac{\partial g_3}{\partial y}\\ \end{array}\right)$$