new version of computing Dx and Dy matrices