# Electric quadrupole - tensor identity

In classical electrodynamics, we introduce the electric quadrupole moment $$D^{ij}\equiv\int y^i y^j \rho \mathrm{d}^3y$$ and its reduced (trace-less) version $$\mathcal{D}^{ij}\equiv D^{ij} - \frac{1}{3}\delta^{ij}D^{kk}, \;\;\;\; \mathcal{D^{ii}}=0.$$ How could I prove that $$\dddot{D}^{ij}\dddot{D}^{ij}-\frac{1}{3}\dddot{D}^{ii} \dddot{D}^{jj} = \dddot{\mathcal{D}}^{ij}\dddot{\mathcal{D}}^{ij}?$$

I tried to compute $$\dot{D}^{ij}=\int y^i y^j \dot{\rho}\mathrm{d}^3y=\int y^i y^j\partial_k j^k\mathrm{d}^3y=\int\partial_k\left(y^i y^j\right)j^k \mathrm{d}^3y=\int\left(y^j j^i + y^i j^j\right)\mathrm{d}^3y,$$ using the continuity equation, integrating by parts and since we can assume that $$j^i$$ has compact spatial support. But I'm not sure this is a smart way to proceed.

Setting $$X=\dddot{D}$$ and $$\mathcal{X}=\dddot{\mathcal{D}}$$ just to avoid having to write all the dots, both $$X$$ and $$\mathcal{X}$$ are symmetric tensors, and in matrix form we can write (just by differentiating your starting equation) $$\mathcal{X}=X-\frac{1}{3} \text{Tr}(X) \mathbb{1}$$ where $$\mathbb{1}$$ is the unit matrix. So $$\mathcal{X}^2 =X^2 - \frac{2}{3} \text{Tr}(X)\, X + \frac{1}{9}[\text{Tr}(X)]^2 \mathbb{1}$$ and hence taking the trace $$\text{Tr} (\mathcal{X}^2) =\text{Tr}(X^2) - \frac{1}{3} [\text{Tr}(X)]^2$$ which is your target equation.