# 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 Chern-Mather 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 ⨯ n}$ integer matrix of rank $d$ which has the length $n$ vector $\mathrm{\left(1,1,1,...,1\right)}$ in its row space and let ${X}_{A}$ be the $\mathrm{\left(d-1\right)}$-dimensional toric variety in ${\mathbb{P}}^{\mathrm{n-1}}$ defined by the polytope $\mathrm{Conv\left(A\right)}$.

The EDPolytope package gives methods to compute:

• The Euclidean distance degree of ${X}_{A}$, $\mathrm{EDdeg\left(}{X}_{A}\right)$.
• The polar degrees of ${X}_{A}$, $\left({\delta }_{0}\left({X}_{A}\right)\mathrm{,...,}{\delta }_{d-1}\left({X}_{A}\right)\right)$.
• The Chern-Mather class of ${X}_{A}$ and the Chern-Mather volumes of the polytope $\mathrm{Conv\left(A\right)}$.

### 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{\left(n-2\right) ⨯ n}$ matrix $A$ of rank $\mathrm{n-2}$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space so that ${X}_{A}$ is a codimension two projective toric variety.
• Output: The integer $\mathrm{EDdeg\left(}{X}_{A}\right)$. Additionally text output is displayed showing both the sums of the Chern-Mather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv\left(A\right)}$ (starting from dimension zero) and the list of polar degrees.
• PolarDegreesCD2:
• Input: An integer $\mathrm{\left(n-2\right) ⨯ n}$ matrix $A$ of rank $\mathrm{n-2}$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space so that ${X}_{A}$ is a codimension two projective toric variety.
• Output: A list containing the polar degrees $\left({\delta }_{0}\left({X}_{A}\right)\mathrm{,...,}{\delta }_{d-1}\left({X}_{A}\right)\right)$. Additionally text output is displayed showing both the sums of the Chern-mather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv\left(A\right)}$ (starting from dimension zero) and the ED degree of the corresponding toric variety ${X}_{A}$.
• CMClassCD2:
• Input: An integer $\mathrm{\left(n-2\right) ⨯ n}$ matrix $A$ of rank $\mathrm{n-2}$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space so that ${X}_{A}$ is a codimension two projective toric variety.
• Output: The Chern-Mather class, ${c}_{M}\left({X}_{A}\right)$, in the Chow ring of ${\mathbb{P}}^{\mathrm{n-1}}$. 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\left(}{X}_{A}\right)$ and the polar degrees.
• CMVolumesCD2:
• Input: An integer $\mathrm{\left(n-2\right) ⨯ n}$ matrix $A$ of rank $\mathrm{n-2}$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space so that ${X}_{A}$ is a codimension two projective toric variety.
• Output: A list of the sums of the Chern-Mather volumes of all faces of each codimension in the corresponding polytope $\mathrm{Conv\left(A\right)}$, starting with codimension zero.
The methods below are the general purpose methods implemented in the first EDPolytope package based on the results from the article Nearest Points on Toric Varieties .
• EDdeg:
• Input: An integer $\mathrm{d ⨯ n}$ matrix $A$ of rank $d$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space.
• Output: The integer $\mathrm{EDdeg\left(}{X}_{A}\right)$. Additionally text output is displayed showing both the sums of the Chern-Mather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv\left(A\right)}$ (starting from dimension zero) and the list of polar degrees.
• PolarDegrees:
• Input: An integer $\mathrm{d ⨯ n}$ matrix $A$ of rank $d$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space.
• Output: A list containing the polar degrees $\left({\delta }_{0}\left({X}_{A}\right)\mathrm{,...,}{\delta }_{d-1}\left({X}_{A}\right)\right)$. Additionally text output is displayed showing both the sums of the Chern-mather volumes of all faces of each dimension in the corresponding polytope $\mathrm{Conv\left(A\right)}$ (starting from dimension zero) and the ED degree of the corresponding toric variety ${X}_{A}$.
• CMClass:
• Input: An integer $\mathrm{d ⨯ n}$ matrix $A$ of rank $d$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space.
• Output: The Chern-Mather class, ${c}_{M}\left({X}_{A}\right)$, in the Chow ring of ${\mathbb{P}}^{\mathrm{n-1}}$. 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\left(}{X}_{A}\right)$ and the polar degrees.
• CMVolumes:
• Input: An integer $\mathrm{d ⨯ n}$ matrix $A$ of rank $d$ with $\mathrm{\left(1,1,1,...,1\right)}$ in its row space.
• Output: A list of the sums of the Chern-Mather volumes of all faces of each codimension in the corresponding polytope $\mathrm{Conv\left(A\right)}$, 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\left(}{X}_{A}\right)$, the polar degrees of ${X}_{A}$, the degree of ${X}_{A}$, the degree of the dual variety, the list of Chern-Mather volumes (starting from dimension zero), and the Chern-Mather class of ${X}_{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.

### The Article

Martin Helmer, Bernt Ivar Utstøl Nødland. Polar Degrees and Closest Points in Codimension Two