# EDPolytope: A Package to Compute the Euclidean Distance Degree of A Toric Variety

This page is supplementary material for the article Nearest Points on Toric Varieties by Martin Helmer and Bernd Sturmfels. It describes Version 2.2 of a Macaulay2 package to compute the Euclidean distance degree, polar degrees and Chern-Mather class of a projective toric variety. A download link and examples of use are given below. The package is implemented in Macaulay2 and the internal methods make use of the Polyhedra package. The package is called "EDPolytope.m2" and may be loaded with the command: needsPackage "EDPolytope".

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)}$.

### Examples

To apply the EDPolytope package to Example 3.3 from Nearest Points on Toric Varieties we would enter the following:  needsPackage "EDPolytope"; A=transpose matrix{{1,0,1},{0,1,1},{1,1,1},{2,1,1},{3,1,1},{1,2,1}}; pds=PolarDegrees(A); ed=EDdeg(A); cm=CMClass(A);  We may compute the ED degree and polar degrees of the hypersimplex ${\Delta }_{4,2}$, which are given in the first row in Table 1 (on page 17) of Nearest Points on Toric Varieties, as follows:  needsPackage "EDPolytope"; A=hyperSimplexVertices(4,2); PolarDegrees(A); EDdeg(A); cm=CMClass(A);  Alternatively we can have the program return a HashTable with all the computed invariants, either EDdeg, PolarDegrees, or CMClass may be used for this purpose and will return the same HashTable. In the hypersimplex example above this would be done as:  needsPackage "EDPolytope"; A=hyperSimplexVertices(4,2); Invar=PolarDegrees(A,Output=>HashTable); Invar=EDdeg(A,Output=>HashTable); Invar#"ED" Invar#"polar degrees" Invar#"degree" Invar#"dual degree" Invar#"CM volumes" Invar#"CM class"