EDPolytopeCD2: A Package to Compute the Euclidean Distance Degree and Polar Degrees of A Toric Variety with Enhancements in Codimension 2
This page is supplementary material for the article Polar Degrees and Closest Points in Codimension Two by Martin Helmer and Bernt Ivar Utstøl Nødland. It describes Version 2.5 of a Macaulay2 package to compute the Euclidean distance degree, polar degrees and ChernMather class of a projective toric variety combinitorially with speed enhancments in the codimension two case. A download link and examples of use are given below. The package is implemented in Macaulay2. The package is called "EDPolytopeCD2.m2" and may be loaded with the command: needsPackage "EDPolytopeCD2".
A version of this package will be available in future releases of Macaulay2 under the name ToricInvariants.
Description
Let $A$ be a $\mathrm{d\; \u2a2f\; n}$ integer matrix of rank $d$ which has the length $n$ vector $\mathrm{(1,1,1,...,1)}$ in its row space and let ${X}_{\mathrm{A}}$ be the $\mathrm{(d1)}$dimensional toric variety in ${\mathbb{P}}^{\mathrm{n1}}$ defined by the polytope $\mathrm{Conv(A)}$.The EDPolytope package gives methods to compute:
 The Euclidean distance degree of ${X}_{\mathrm{A}}$, $\mathrm{EDdeg(}{X}_{\mathrm{A}})$.
 The polar degrees of ${X}_{\mathrm{A}}$, $({\delta}_{0}({X}_{\mathrm{A}})\mathrm{,...,}{\delta}_{\mathrm{d1}}({X}_{\mathrm{A}}))$.
 The ChernMather class of ${X}_{\mathrm{A}}$ and the ChernMather volumes of the polytope $\mathrm{Conv(A)}$.
Methods
The first three methods are for codimension two toric varieties only. These methods use the Gale dual matrix $B$ of $A$ internally (as described in Polar Degrees and Closest Points in Codimension Two) and will provide increased performance vs. the general purpose methods below.
EDdegCD2:
 Input: An integer $\mathrm{(n2)\; \u2a2f\; n}$ matrix $A$ of rank $\mathrm{n2}$ with $\mathrm{(1,1,1,...,1)}$ in its row space so that ${X}_{\mathrm{A}}$ is a codimension two projective toric variety.
 Output: The integer $\mathrm{EDdeg(}{X}_{\mathrm{A}})$. Additionally text output is displayed showing both the sums of the ChernMather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv(A)}$ (starting from dimension zero) and the list of polar degrees.

PolarDegreesCD2:
 Input: An integer $\mathrm{(n2)\; \u2a2f\; n}$ matrix $A$ of rank $\mathrm{n2}$ with $\mathrm{(1,1,1,...,1)}$ in its row space so that ${X}_{\mathrm{A}}$ is a codimension two projective toric variety.
 Output: A list containing the polar degrees $({\delta}_{0}({X}_{\mathrm{A}})\mathrm{,...,}{\delta}_{\mathrm{d1}}({X}_{\mathrm{A}}))$. Additionally text output is displayed showing both the sums of the Chernmather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv(A)}$ (starting from dimension zero) and the ED degree of the corresponding toric variety ${X}_{\mathrm{A}}$.

CMClassCD2:
 Input: An integer $\mathrm{(n2)\; \u2a2f\; n}$ matrix $A$ of rank $\mathrm{n2}$ with $\mathrm{(1,1,1,...,1)}$ in its row space so that ${X}_{\mathrm{A}}$ is a codimension two projective toric variety.
 Output: The ChernMather class, ${c}_{\mathrm{M}}({X}_{\mathrm{A}})$, in the Chow ring of ${\mathbb{P}}^{\mathrm{n1}}$. We use the symbol $h$ to represent the rational equivalence class of a hyperplane in the Chow ring. Additionally text output is displayed showing $\mathrm{EDdeg(}{X}_{\mathrm{A}})$ and the polar degrees.

CMVolumesCD2:
 Input: An integer $\mathrm{(n2)\; \u2a2f\; n}$ matrix $A$ of rank $\mathrm{n2}$ with $\mathrm{(1,1,1,...,1)}$ in its row space so that ${X}_{\mathrm{A}}$ is a codimension two projective toric variety.
 Output: A list of the sums of the ChernMather volumes of all faces of each codimension in the corresponding polytope $\mathrm{Conv(A)}$, starting with codimension zero.

EDdeg:
 Input: An integer $\mathrm{d\; \u2a2f\; n}$ matrix $A$ of rank $d$ with $\mathrm{(1,1,1,...,1)}$ in its row space.
 Output: The integer $\mathrm{EDdeg(}{X}_{\mathrm{A}})$. Additionally text output is displayed showing both the sums of the ChernMather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv(A)}$ (starting from dimension zero) and the list of polar degrees.

PolarDegrees:
 Input: An integer $\mathrm{d\; \u2a2f\; n}$ matrix $A$ of rank $d$ with $\mathrm{(1,1,1,...,1)}$ in its row space.
 Output: A list containing the polar degrees $({\delta}_{0}({X}_{\mathrm{A}})\mathrm{,...,}{\delta}_{\mathrm{d1}}({X}_{\mathrm{A}}))$. Additionally text output is displayed showing both the sums of the Chernmather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv(A)}$ (starting from dimension zero) and the ED degree of the corresponding toric variety ${X}_{\mathrm{A}}$.

CMClass:
 Input: An integer $\mathrm{d\; \u2a2f\; n}$ matrix $A$ of rank $d$ with $\mathrm{(1,1,1,...,1)}$ in its row space.
 Output: The ChernMather class, ${c}_{\mathrm{M}}({X}_{\mathrm{A}})$, in the Chow ring of ${\mathbb{P}}^{\mathrm{n1}}$. We use the symbol $h$ to represent the rational equivalence class of a hyperplane in the Chow ring. Additionally text output is displayed showing $\mathrm{EDdeg(}{X}_{\mathrm{A}})$ and the polar degrees.

CMVolumes:
 Input: An integer $\mathrm{d\; \u2a2f\; n}$ matrix $A$ of rank $d$ with $\mathrm{(1,1,1,...,1)}$ in its row space.
 Output: A list of the sums of the ChernMather volumes of all faces of each codimension in the corresponding polytope $\mathrm{Conv(A)}$, starting with codimension zero.
For use by programmers; in all methods above, except CMVolumes and CMVolumesCD2, the user may optionally ask for the output in the form of a HashTable containing all computed information including $\mathrm{EDdeg(}{X}_{\mathrm{A}})$, the polar degrees of ${X}_{\mathrm{A}}$, the degree of ${X}_{\mathrm{A}}$, the degree of the dual variety, the list of ChernMather volumes (starting from dimension zero), and the ChernMather class of ${X}_{\mathrm{A}}$. This option is accessed by specifying Output=>HashTable
, see the example below. Additional text output may also be requested using the option TextOutput=>"All"
.
Examples
To apply the EDPolytope package to Example 2.1 from Polar Degrees and Closest Points in Codimension Two we would enter the following:
needsPackage "EDPolytopeCD2";
A=matrix{{2,2,1,0,0},{4,0,0,1,0},{1,1,1,1,1}} ;
pds=PolarDegreesCD2(A);
ed=EDdegCD2(A);
cm=CMClassCD2(A);
For examples of the general purpose (i.e. any codimension) methods "EDdeg", "PolarDegrees", "CMClass", and "CMVolumes" see the documentation for version 2.2 of the EDPolytope package here: EDPolytope package.
Download
The package file "EDPolytopeCD2.m2" may be downloaded below: EDPolytopeCD2 package for Macaulay2 Version 1.10 and above.
 EDPolytopeCD2 package for Macaulay2 Version 1.9 and below.