Error in the tree diagram of the chain rule? I was given a problem, we define:
$$z(x,y) = x\sin(y^2), y(x) = 2x+1.$$
We wish to use the chain rule to compute $\frac{\partial z}{\partial x}.$ I know, I can get the correct answer using the Jacobian; however, the tree diagram fails me I this regard because,
$$ \frac{\partial z}{\partial x} = \frac{\partial z}{\partial x} + \frac{\partial z}{\partial y}\frac{\partial y}{\partial x}.$$
Obviously, we have a problem here. Am I misunderstanding something?
 A: In fact, this is only a problem of abused notations. $z$ is a map of two variables, that we usually denote by $x$ and $y$.
Then to avoid any notation issue, we should denote with another letter the map $z(x,y(x))$. For example write $Z(x) = z(x,y(x))$. And what you're looking for is to compute, using the chain rule:
$$\begin{aligned}\frac{dZ}{dx}(x)&= \frac{\partial z}{\partial x}(x,y(x)) + \frac{\partial z}{\partial y}(x,y(x))\frac{\partial y}{\partial x}(x)\\
&=\sin y^2(x) + 2y(x) \cos y^2(x) \times 2\\
&= \sin((2x+1)^2)+ 4(2x+1)\cos((2x+1)^2)
\end{aligned}$$
With the correct notation above, there is no issue at all.
A: Hopefully, this can clear things up.
If we have $z=f(x,y)$ and $y=g(x)$, then the chain rule for $\frac{dz}{dx}$ becomes
$$\frac{dz}{dx} = \frac{\partial f}{\partial x}\cdot \frac{dx}{dx} + \frac{\partial f}{\partial y}\cdot \frac{dy}{dx} = \frac{\partial f}{\partial x} + \frac{\partial f}{\partial y}\cdot \frac{dy}{dx}$$
where we use the fact that $\frac{dx}{dx} = 1$.
Using that formula on $z=f(x,y)=x\sin{\left(y^2\right)}$, you should get
$$\frac{\partial f}{\partial x} + \frac{\partial f}{\partial y}\cdot \frac{dy}{dx} = \sin\left(y^{2}\right)+x\cos\left(y^{2}\right)\left(2y\right)\left(2\right).$$
Plug in $y=2x+1$ and it should be the same answer as using the Jacobian method.
