The local matrix is a gauge transformation in the representation acting on the matter field. With Hermitian Lie algebra generators it can be written locally in spacetime, and pointwise for , as
The real functions can instead include a factor of by redefining the transformation parameters. The gauge covariant derivative convention in this paper is . Inserting the stated transformed shows explicitly that the term cancels, giving .
In QCD, each quark field is in the colour fundamental representation , with . Thus its colour generators are eight matrices, conventionally for the Gell-Mann matrices; their number is not their matrix dimension. The eight gluons themselves transform in the adjoint representation of SU(3).
With , the pure Yang-Mills theory has Lagrangian . Put and . Since ,
The cross term has two derivative contributions. Interchange and then in the second; antisymmetry of makes it equal to the first. The cubic and quartic Yang-Mills self-interactions are therefore
The positive cubic sign follows from the negative term in the given Yang-Mills field strength; changing the covariant-derivative convention consistently changes intermediate signs.
For the left-handed quark doublet , the hypercharge is and the weak generators are . Its electroweak term is
The Pauli matrices give diagonal entries and off-diagonal entries . Expanding the term gives
In particular the off-diagonal weak charged current coupling is .
Write , . Invert the neutral-field rotation: , . The original PDF gives , so
The photon coefficients inside the derivative are for , and for . Multiplication by the in the kinetic Lagrangian gives the requested electromagnetic coupling of a weak multiplet:
Equivalently it is , making the electric charges explicit. The remaining neutral terms are . The TeX's missing prime in the mixing-angle ratio and truncated first Pauli matrix are conversion errors, not physical assumptions.