I am facing problem to understand how the exchange potential is calculated for meta-gga functional in NWCHEM. I have seen the pkzb and tpss exchange functional subroutine. I don't understand how the functional derivative of exchange energy is taken with respect to gradient of density and kinetic energy i.e how the matrix Cmat and Mmat is taken in the pkzb and tpss exchange functional. Can anyone please help me.