# diff -- differentiate or take difference

## Synopsis

• Usage:
diff(f,g) or diff(P) or diff(P,i)

## Description

This function has two different uses. The most common use is for differentiation: differentiate the second input by the first.

The second use, less common but sometimes useful, is to compute the difference polynomial of a Hilbert polynomial.

The arguments can also be ring elements or vectors.

 i1 : R = ZZ[x,y,z] o1 = R o1 : PolynomialRing i2 : f = vars R ** vars R o2 = | x2 xy xz xy y2 yz xz yz z2 | 1 9 o2 : Matrix R <--- R i3 : diff(transpose vars R, f) o3 = {1} | 2x y z y 0 0 z 0 0 | {1} | 0 x 0 x 2y z 0 z 0 | {1} | 0 0 x 0 0 y x y 2z | 3 9 o3 : Matrix R <--- R i4 : diff(x, f) o4 = | 2x y z y 0 0 z 0 0 | 1 9 o4 : Matrix R <--- R i5 : diff(y, f) o5 = | 0 x 0 x 2y z 0 z 0 | 1 9 o5 : Matrix R <--- R i6 : diff(z, f) o6 = | 0 0 x 0 0 y x y 2z | 1 9 o6 : Matrix R <--- R