# How to write summation of squared divergence terms in index summation notation?

Sorry if this has already been asked before, but it's really difficult to try and explain the problem in words.

Anyways, I want to express the following:

$$\phi = \left(\frac{\partial u_1}{\partial x_1}\right)^2 + \left(\frac{\partial u_2}{\partial x_2}\right)^2 + \left(\frac{\partial u_3}{\partial x_3}\right)^2$$

My first instinct would be to square the divergence of $$u_i$$, but this would result in:

$$\left(\frac{\partial u_k}{\partial x_k}\right)^2 = \left(\frac{\partial u_1}{\partial x_1} + \frac{\partial u_2}{\partial x_2}+ \frac{\partial u_3}{\partial x_3}\right)^2$$

I've narrowed it down to either of the following, but they both seem more like "hacks" than correct. I've also included the general line of thinking behind the ideas as well.

## Idea 1:

$$\text{Idea 1: }\quad \frac{\partial (u_k)^2}{\partial (x_k)^2}=\frac{\partial (u_1)^2}{\partial (x_1)^2} + \frac{\partial (u_2)^2}{\partial (x_2)^2} + \frac{\partial (u_3)^2}{\partial (x_3)^2} = \left(\frac{\partial u_1}{\partial x_1}\right)^2 + \left(\frac{\partial u_2}{\partial x_2}\right)^2 + \left(\frac{\partial u_3}{\partial x_3}\right)^2$$

This being analogous to:

$$\text{Inspiration for Idea 1:} \quad \frac{(A)^2}{(B)^2} = \left(\frac{A}{B}\right)^2$$

## Idea 2:

$$\text{Idea 2: } \quad \frac{\partial u_k}{\partial x_k}\frac{\partial u_k}{\partial x_k} = \frac{\partial u_1}{\partial x_1}\frac{\partial u_1}{\partial x_1} + \frac{\partial u_2}{\partial x_2}\frac{\partial u_2}{\partial x_2} + \frac{\partial u_3}{\partial x_3}\frac{\partial u_3}{\partial x_3} = \left(\frac{\partial u_1}{\partial x_1}\right)^2 + \left(\frac{\partial u_2}{\partial x_2}\right)^2 + \left(\frac{\partial u_3}{\partial x_3}\right)^2$$

This idea was inspired from the incompressible form of the shear stress equations for fluids:

$$\text{Inspiration for Idea 2:} \quad \frac{\partial^2 \tau_{ij}}{\partial x_j \partial x_j} = \frac{\partial^2 \tau_{i1}}{\partial x_1^2} + \frac{\partial^2 \tau_{i2}}{\partial x_2^2} + \frac{\partial^2 \tau_{i3}}{\partial x_3^2}$$

On a slightly related note, if anyone knows of a good resource that goes over common index summation notation forms of common math expressions or the "rules" of index summation notation, let me know!

Using the Kronecker delta, $$\delta_{ij}$$:
$$\delta_{ij} =\left\{ \begin{array}{ll} 0 & i\not=j \\ 1 & i=j \\ \end{array} \right.$$
$$\left(\frac{\partial u_1}{\partial x_1}\right)^2 + \left(\frac{\partial u_2}{\partial x_2}\right)^2 + \left(\frac{\partial u_3}{\partial x_3}\right)^2 = \frac{\partial u_j}{\partial x_k} \frac{\partial u_j}{\partial x_k} \delta_{jk}$$