# diff(Matrix,RingElement) -- differentiation

## Synopsis

• Function: diff
• Usage:
diff(f,g)
• Inputs:
• f, , a matrix
• g, , a polynomial with the same ring as f
• Outputs:
• the result of differentiating g by the differential operator corresponding to each entry of f.

## 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+y-z)^2) o3 = | 2x+2y-2z 2x+2y-2z -2x-2y+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+y-z)^2) o5 = | 2x+2y-2z -2x-2y+2z | | 2x+2y-2z 0 | 2 2 o5 : Matrix R <--- R