Solution (source code)

= Solution

Write $r=x-a$. The squared <Euclidean norm> is $r^Tr$, whose <gradient> is $2r$. The <chain rule> for the <exponential function> therefore gives the column <gradient>
$$
\boxed{\nabla f(x)=2e^{\|x-a\|^2}(x-a).}
$$
The row <derivative>, if that convention is used for $df/dx$, is its transpose.