Worked out all the derivatives with kronecker products