Macaulay2 » Documentation
Packages » Macaulay2Doc » matrices » diff and contract » diff
next | previous | forward | backward | up | index | toc

# diff -- differentiate or take difference

- 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

## See also

- diff and contract
- diff' -- differentiate a matrix by a matrix, the dual notion
- contract -- contract one matrix by another
- jacobian -- the Jacobian matrix of partial derivatives
- hilbertPolynomial -- compute the Hilbert polynomial

### Menu

#### differentiation

- diff(RingElement,RingElement) -- differentiation
- diff(RingElement,Matrix) -- differentiate each entry of a matrix
- diff(Matrix,RingElement) -- differentiation
- diff(Matrix,Matrix) -- differentiate a matrix by a matrix

#### difference operator for Hilbert polynomials

- diff(ProjectiveHilbertPolynomial)
- diff(ProjectiveHilbertPolynomial,ZZ)

## Ways to use diff:

- diff(Matrix,Matrix) -- differentiate a matrix by a matrix
- `diff(Matrix,Vector)` -- see diff(Matrix,Matrix) -- differentiate a matrix by a matrix
- `diff(RingElement,Vector)` -- see diff(Matrix,Matrix) -- differentiate a matrix by a matrix
- `diff(Vector,Matrix)` -- see diff(Matrix,Matrix) -- differentiate a matrix by a matrix
- `diff(Vector,RingElement)` -- see diff(Matrix,Matrix) -- differentiate a matrix by a matrix
- `diff(Vector,Vector)` -- see diff(Matrix,Matrix) -- differentiate a matrix by a matrix
- diff(Matrix,RingElement) -- differentiation
- diff(ProjectiveHilbertPolynomial)
- diff(ProjectiveHilbertPolynomial,ZZ)
- diff(RingElement,Matrix) -- differentiate each entry of a matrix
- diff(RingElement,RingElement) -- differentiation

## For the programmer

The object diff is a method function.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/functions/diff-doc.m2:165:0.