I know the general formula for the Jacobian of a composition of functions, for example $f(x)=h(g(x))$, is $J_{h(g(x))}=J_f=J_h*J_g$.
I have here the composition: $f(x)=\frac{1}{2}||g(x)||^2$, and so $h(y)=\frac{1}{2}||y||^2$ and $g(x)=x$ in the composition $f(x)=h(g(x))$. where $g(x):\mathbb{R}^k \rightarrow \mathbb{R}^n$ and $h(x):\mathbb{R}^n \rightarrow \mathbb{R}$
I see in my textbook that the $J_f$ is $J_f=\sum_i^n g_i(x)\nabla g_i(x)$ where $i$ is the index of which function we are talking about in the vector of functions $g(x)$. but I cannot prove it to myself that this is true. The dimensions do not match up.
$g_i(x) \in \mathbb{R}$ and $\nabla g_i(x) \in \mathbb{R}^k$.
Now I want to find $J_f$. I know that the dimensions should work out such that $J_g:\mathbb{R}^n\rightarrow\mathbb{R}^k$ and $J_h:\mathbb{R}\rightarrow\mathbb{R}^n$, and hence $J_f$ will be of dimension $1$ by $ k$ .
Is my textbook wrong? I cannot see how these dimensions will work out.
If $g:\Bbb R^k \to \Bbb R^n$ then $J_{g(x)} : \Bbb R^k \to \Bbb R^n$ and similarly $J_{h(g(x))} : \Bbb R^n \to \Bbb R$.
So:$$J_{(h \circ g)(x)} : \Bbb R^k \to \Bbb R$$ and: $$J_{h(g(x))} \cdot J_{g(x)} : \Bbb R^n \to \Bbb R$$ so there is no problem.
In your textbook $J_f$ is from $\Bbb R^k$ to $\Bbb R^k$. It means that for $x \in \Bbb R^k$, $J_{f(x)} \in \Bbb R^k$. This is because there is an identification between $(\Bbb R^k)^*$ and $\Bbb R^k$.
To be precise for a function from $\Bbb R^k$ to $\Bbb R$ you define the gradient as the transpose of the jacobian, so the "correct" way of writing it should be:
$$\nabla f (x)=\left(J_{f(x)} \right)^T=\sum_i^n g_i(x)\nabla g_i(x)$$