Solution (source code)

= Solution

In Cartesian components, $\mathbf a\cdot\mathbf r=a_xx+a_yy+a_zz$, with constant $a_i$. Taking the <gradient> component by component gives
$$
\boxed{\nabla(\mathbf a\cdot\mathbf r)=\mathbf a.}
$$
The constancy of $\mathbf a$ matters: if it depended on position, derivatives of its components would also contribute.