# Partial differentiation of composite functions

How can I differentiate the function below where $y = y(x_1 , x_2 )$? $$\frac{\partial}{\partial x_1} \left( f \left( \frac{\partial y}{\partial x_1} , \frac{\partial y }{\partial x_2} \right) \right) = ?$$ Here all the functions are sufficiently differentiable, $f$ is a function of the partials of $y$.

-

You can still use the multivariable chain rule, just think of the partial derivatives $y_{x_1}$ and $y_{x_2}$ as your 'middle' variables. Recall:

$$\frac{\partial}{\partial x_1} f(y_1(x_1,x_2)),y_2(x_1,x_2))=\frac{\partial f}{\partial y_1}\frac{\partial y_1}{\partial x_1}+\frac{\partial f}{\partial y_2}\frac{\partial y_2}{\partial x_1}$$

So here we can set $y_1=\frac{\partial y}{\partial x_1}$ and $y_2=\frac{\partial y}{\partial x_2}$ to obtain:

$$\frac{\partial f}{\partial x_1}=\frac{\partial f}{\partial y_1}\frac{\partial y_1}{\partial x_1}+\frac{\partial f}{\partial y_2}\frac{\partial y_2}{\partial x_1}\\ =\frac{\partial f}{\partial y_1}\frac{\partial^2y}{\partial x_1^2}+\frac{\partial f}{\partial y_2}\frac{\partial^2 y}{\partial x_2x_1}$$

Here is an example (easy to construct but the details are messy). Let $y(x_1,x_2)=\frac{x_1^2x_2^2}{2}$. Then, $y_1=y_{x_1}=x_1x_2^2$ and $y_2=y_{x_2}=x_2x_1^2$. Let $f(y_1,y_2)=\sin(y_1^2+y_2^2)$. Then,

$$f(y_{x_1},y_{x_2})=f\left(y_1,y_2\right)=\sin(x_1^2x_2^4+x_2^2x_1^4)$$

$$\frac{\partial f}{\partial x_1}=\frac{\partial f}{\partial y_1}\frac{\partial y_1}{\partial x_1}+\frac{\partial f}{\partial y_2}\frac{\partial y_2}{\partial x_1}\\ =\frac{\partial }{\partial y_1}\sin(y_1^2+y_2^2)\frac{\partial y_1}{\partial x_1}+\frac{\partial }{\partial y_2}\sin(y_1^2+y_2^2)\frac{\partial y_2}{\partial x_1}\\ =2y_1\cos(y_1^2+y_2^2)\frac{\partial}{\partial x_1}(x_1x_2^2)+2y_2\cos(y_1^2+y_2^2)\frac{\partial}{\partial x_1}(x_2x_1^2)\\ =2x_1x_2^2\cos(y_1^2+y_2^2)x_2^2+2x_2x_1^1\cos(y_1^2+y_2^2)x_1^2\\ =(2x_1x_2^4+2x_2x_1^4)\cos(x_1^2x_2^4+x_2^2x_1^4)$$

-