I am struggling to find the first derivative of a composed function with several variables. I think the solution of the problem involves the chain rule or some generalised form, but I can not see how to do it. Any hint or help is appreciated.
The situation: Lets assume we have variables $x_1, \dots, x_4$. These are transformed by a function $f$, which returns more than the given $4$ parameters.
For example: $ f: \mathbb{R}^4 \rightarrow \mathbb{R}^6, \quad x_1, x_2, x_3, x_4 \rightarrow (0, x_1 + x_3, 2 \cdot x_1 + x_4, 0, x_2 + x_3, 2 \cdot x_2 + x_4) $
The 'output' of $f$, let us call it $\mathbf{y} = (y_1, y_2, \dots, y_6)$, is processed by another function $g$ which is defined as followed: $g:\mathbb{R}^6 \rightarrow \mathbb{R}^6, (y_1, y_2, \dots, y_6) \rightarrow (\exp(-y_1), \exp(-y_2), \dots, \exp(-y_6))$
Then we have a third function $h$ which takes the 'output' of $g$, let us call this 'output' $\mathbf{z} = (z_1, z_2, \dots, z_6)$, and processes it further, returning some single value, so we have $h: \mathbb{R}^6 \rightarrow \mathbb{R}$. (I will not show the concrete definition of $h$, because I do not think it does help, but rather complicates things.)
What I am looking for is the first derivative of $h$ with respect to the original four parameters $x_1, \dots, x_4$.
What I tried is to apply the simple chain rule, like in the following. But I am not shure if this is correct or if I do miss something. Let's say we are interested in the first derivative of $h$ with respect to $x_2$. Then I got the following with the simple chain rule: $ \frac{\partial h}{\partial x_4} = \frac{dh}{d\mathbf{z}} \cdot \frac{dg}{d\mathbf{y}} \cdot \frac{\partial f}{\partial x_2} $
While writing this question, I ask myself if I need some 'partial derivative' of $h$ and $g$, but with respect to which parameter? All involving $x_2$?
Any help or hints will be appreciated. Thank you!
Best, Michael