# Vector norm in tensor notation

Just starting out with tensor notation. I'm trying to express a vector sum (norm) in tensor notation and its derivative. Suppose we have

$s = \sum_k (a_k - b_k)^2$

What would be the natural way to write this in tensor notation?

$s = (a_i-b_i)\delta_{i,j}(a_j - b_j)$

$s = a_i \delta_{i,j} a_j - b_i \delta_{i,j} a_j - a_i \delta_{i,j} b_j + b_i \delta_{i,j}b_j$

With a set of derivatives wrt elements of $a$:

$\frac{\partial s}{\partial a_k} = \frac{\partial a_i \delta_{i,j} a_j}{\partial a_k} - \frac{\partial b_i \delta_{i,j} a_j}{\partial a_k} - \frac{\partial a_i \delta_{i,j} b_j}{\partial a_k} - \frac{\partial b_i \delta_{i,j} b_j}{\partial a_k}$

$= 2a_k - b_k - b_k = 2 a_k - 2 b_k$

Something feels naughty about dropping the $\delta$s like that. But after differentiation they were unity at all values of interest and if they'd been left in there would have been an implication I should sum over $\delta_{k,k}$

You don't need to use the $\delta_{ij}$ symbols. You can just write
$$s=(a_i-b_i)(a_i-b_i)=a_ia_i-2a_ib_i+b_ib_i$$ $$\frac{\partial s}{\partial a_k}=\frac{\partial a_ia_i}{\partial a_k}-2\frac{\partial a_ib_i}{\partial a_k}+\frac{\partial b_ib_i}{\partial a_k}=2a_k-2b_k+0$$