Gauge invariance of Yang-Mills lagrangian

I am trying to show gauge invarince of the Yang-Mills lagrangian

$$\mathcal{L}= -\frac{1}{4}F_{\mu \nu }^{a}F^{\mu \nu ,a}+\sum_{i,j}^{N}\overline{\psi}_{i} (\delta _{ij}i\partial_{\alpha}\gamma^{\alpha } -\delta _{ij}m+gA_{\alpha }^{a}\gamma^{ \alpha } T^{a}_{ij})\psi_{j},$$ by rewriting it in terms of the covariant derivative $$D_{\mu}=\partial_{\mu}-igA^{a}_{\mu}T^{a},$$ for which I know that $$F_{\mu \nu }=\frac{i}{g}[D_{\mu},D_{\nu}],$$ (where $$F_{\mu \nu }=F_{\mu \nu }^{a}T^{a}$$) and that it transforms as $$D_{\mu} \rightarrow U(x)D_{\mu}U^{-1}(x)$$ under the gauge transformation. I am stuck with the following two questions:

• When evaluating the transformation of the first term, I have seen the idendity $$-\frac{1}{4}F_{\mu \nu }^{a}F^{\mu \nu ,a}=-\frac{1}{2}F_{\mu \nu }^{a}F^{\mu \nu ,b}\text{tr}[T^{a}T^{b}]=-\frac{1}{2} \text{tr} [F_{\mu \nu }F^{\mu \nu}]$$ been used, but I dont understand the second equality. The components of the Yang-Mills field tensor are matrices, so how does one justify including them in the trace? (It is understood that that $$T^{a}$$ matrices has been normalized so that $$\text{tr}[T^{a}T^{b}]=\frac{1}{2}\delta^{ab}$$ by the way.)

• For the second term of the lagrangian I have seen the equality $$\sum_{i,j}^{N}\overline{\psi}_{i} (\delta _{ij}i \partial_{\alpha}\gamma^{\alpha }-\delta _{ij}m+gA_{\alpha }^{a}\gamma^{ \alpha } T^{a}_{ij})\psi_{j} =\sum_{i,j}^{N}\overline{\psi}_{i} ( i D_{ij, \alpha}\gamma^{\alpha }-\delta _{ij}m)\psi_{j},$$ been used, but I don't understand how this is true unless $$gA_{\alpha }^{a}\gamma^{ \alpha } T^{a}_{ij}=0$$ for $$i\neq j$$. I am very eager to know why this equality holds?

In the first point you're wrong in the normalisation condition which is $$\text{Tr}(T^aT^b) = \frac{1}{2}\delta^{ab}$$ and it couldn't be $$\delta_{ij}$$ since you're tracing over the indices $$\text{Tr}(T^aT^b) =T^a_{ij}T^b_{ji}$$ With this the first result is trivial.
The second point just comes from the definition of the covariant derivative $$D_\mu = \partial_\mu-igA_\mu^aT^a$$ in which the internal indices are understood. If you write them down you would get $$(D_{\mu})_{ij} =\partial_\mu\delta_{ij}-igA_\mu^aT^a_{ij}$$ in fact $$i\bar\psi_i (D_\mu)_{ij}\gamma^\mu\psi_j = i\bar\psi_i\left(\partial_\mu\gamma^\mu\delta_{ij}-igA_\mu^a\gamma^\mu T^a_{ij}\right)\psi_j = \bar\psi_i\delta_{ij}i\gamma^\mu\partial_\mu\psi_j+g\bar\psi_i\gamma^\mu A_\mu^aT^a_{ij}\psi_j$$ which is exactly what you have in the second equality
• ...delta function and not on the partial derivative directly (without any delta function)? Well, I understand the partial derivative can't have indeces, but why would the derivative be zero for $i \neq j$? Commented Jun 1, 2020 at 21:39
• The partial derivative has not internal indices, it shouldn't. In the same manner as the photon field has no internal indices. You have to be careful with indices: $\mu$ is a Lorentz inde, $a$ is an internal index, for example a colour index if the theory is $SU(3)$, $i,j$ are spinor indices. There's no reason for the partial derivative to have spinor indices nor color ones. The covariant derivative however depends on the representation of the theory and so has spinor indices since it acts differently on different components of the spinor due to the $T^a_{ij}$. Commented Jun 1, 2020 at 22:04