Gradient of $f(x)$ How to calculate the gradient of $f(x).$ 
$f(x) = \dfrac{1}{2} \|C\|^2$
$C = A\,\,{.\!^*}\,B$ .... element-wise multiplication
Volume $A$ has the dimensions $(x,y,z)=(3,3,3)$ and $B$ has the same size as $A.$ 
The element-wise product $C$ has the same size as $A$ and $B$. 
$\dfrac{\partial f(x)}{\partial C} = \left(\dfrac{\partial f(x)}{\partial A},\dfrac{\partial f(x)}{\partial B}\right)$
I am using the chain rule: 
$\dfrac{\partial f(x)}{\partial A} = \dfrac{\partial f(x)}{\partial C} \dfrac{\partial C}{\partial A} = \|C\| B$ 
$\dfrac{\partial f(x)}{\partial A} = \dfrac{\partial f(x)}{\partial C} \dfrac{\partial C}{\partial B} = \|C\| A$ 
And now the Euclidean norm must give a scalar, which is multiplied by $B$ or $A?$
 A: It can be helpful in these sorts of situations to write out what you've got:
\begin{align*}
f(x)&=\frac12 \|C\|^2=\frac12 (C_x^2+C_y^2+C_z^2)\\
&=\frac12 [(A_xB_x)^2+(A_yB_y)^2+(A_zB_z)^2].
\end{align*}
Now, it's not clear to me that
$$\dfrac{\partial f(x)}{\partial C} = \left(\dfrac{\partial f(x)}{\partial A},\dfrac{\partial f(x)}{\partial B}\right)$$
is correct. Wouldn't it rather be
$$\dfrac{\partial f(x)}{\partial C} = \left(\dfrac{\partial f(x)}{\partial C_x},\dfrac{\partial f(x)}{\partial C_y},\dfrac{\partial f(x)}{\partial C_z}\right)?$$
In that case, you'd have
$$\dfrac{\partial f(x)}{\partial C} = \left(\dfrac{\partial f(x)}{\partial \|C\|}\dfrac{\partial \|C\|}{\partial C_x},\;\dfrac{\partial f(x)}{\partial \|C\|}\dfrac{\partial \|C\|}{\partial C_y},\;\dfrac{\partial f(x)}{\partial \|C\|}\dfrac{\partial \|C\|}{\partial C_z}\right),$$
or you could even do (which would be easier):
\begin{align*}\dfrac{\partial f(x)}{\partial C} &= \left(\dfrac{\partial f(x)}{\partial (\|C\|^2)}\dfrac{\partial (\|C\|^2)}{\partial C_x},\;\dfrac{\partial f(x)}{\partial (\|C\|^2)}\dfrac{\partial (\|C\|^2)}{\partial C_y},\;\dfrac{\partial f(x)}{\partial (\|C\|^2)}\dfrac{\partial (\|C\|^2)}{\partial C_z}\right)\\&=\left(\|C\|C_x,\|C\|C_y,\|C\|C_z\right) \\
&=\|C\|(C_x,C_y,C_z)\\
&=\|C\|C.
\end{align*}
Not sure how $A$ and $B$ necessarily need to go into the problem.
