# Why can I use the chain rule when finding the Jacobian of this function?

Suppose I've the following multivarible function

\begin{align} e_k(x) = e_k \left( \begin{bmatrix}\phi_1 \\ \theta_1 \\ \phi_2 \\ \theta_2 \end{bmatrix} \right) = \begin{bmatrix} e(1) \\ e(2) \\ \vdots \\ e(k) \end{bmatrix} &= \begin{bmatrix} ||\hat{j}_1 \times g_1(t_1)||_2 - ||\hat{j}_2 \times g_2(t_1)||_2 \\ ||\hat{j}_1 \times g_1(t_2)||_2 - ||\hat{j}_2 \times g_2(t_2)||_2 \\ \vdots \\ ||\hat{j}_1 \times g_1(t_k)||_2 - ||\hat{j}_2 \times g_2(t_k)||_2 \end{bmatrix} \end{align}

where $\hat{j}_i$ (for $i=1..2$) is the unit vector representation of $j_i$, and we have $$\hat{j}_1={(\operatorname{cos}(\phi_1)\operatorname{cos}(\theta_1),\operatorname{cos}(\phi_1)\operatorname{sin}(\theta_1),\operatorname{sin}(\phi_1))}^T$$

and

$$\hat{j}_2={(\operatorname{cos}(\phi_2)\operatorname{cos}(\theta_2),\operatorname{cos}(\phi_2)\operatorname{sin}(\theta_2),\operatorname{sin}(\phi_2))}^T$$

Now, apparently, it seems that the first row of the Jacobian of $e_k(x)$ can be obtained as follows

\begin{align*} \begin{bmatrix} \frac{\partial e_1}{ \partial \hat{j_1}} \frac{\partial \hat{j_1}}{\partial \phi_1} & \frac{\partial e_1}{ \partial \hat{j_1}} \frac{\partial \hat{j_1}}{\partial \theta_1} & \frac{\partial e_1}{ \partial \hat{j_2}} \frac{\partial \hat{j_2}}{\partial \phi_2} & \frac{\partial e_1}{ \partial \hat{j_2}} \frac{\partial \hat{j_2}}{\partial \theta_2} \end{bmatrix} \end{align*}

and $g_i(t_k)$ are $3D$ vectors which are not defined in terms of the input vector $x$, so they are somehow constant vectors.

Why exactly can we use here the chain rule? And why in that way?

• Each term in $e(i)$ can be written as a composition. The chain rule tells you how to differentiate a composition. What you call $\hat{j_1}$ is a function $\Bbb{R}^4 \to \Bbb{R}^3$, and then taking the cross product with the fixed vector $g_1$ is a function from $\Bbb{R}^3$ to $\Bbb{R}^3$, and finally taking the norm is a function $\Bbb{R}^3 \to \Bbb{R}$. – Nick Mar 27 '17 at 13:59
• @Nick Ok, but how exactly (more in detail, i.e. I understood we have a composition and that the chain rule is applied to composition of functions...) does this explain the apparent solution I'm providing in my question above? – nbro Mar 27 '17 at 14:13