Description
The shape of the resulting matrix is the same as the shape of f, but the degrees of the source module are different in an attempt to ensure that the result is homogeneous.
i1 : R = QQ[x,y,z,q];

i2 : f = vars R
o2 =  x y z q 
1 4
o2 : Matrix R < R

i3 : diff(f, (x+yz)^2)
o3 =  2x+2y2z 2x+2y2z 2x2y+2z 0 
1 4
o3 : Matrix R < R

i4 : f2 = genericMatrix(R,2,2)
o4 =  x z 
 y q 
2 2
o4 : Matrix R < R

i5 : diff(f2, (x+yz)^2)
o5 =  2x+2y2z 2x2y+2z 
 2x+2y2z 0 
2 2
o5 : Matrix R < R
