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.


Let A be a d ⨯ n integer matrix of rank d which has the length n vector (1,1,1,...,1) in its row space and let XA be the (d-1)-dimensional toric variety in Pn-1 defined by the polytope Conv(A).

The EDPolytope package gives methods to compute:


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. 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 .

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 EDdeg(XA), the polar degrees of XA, the degree of XA, the degree of the dual variety, the list of Chern-Mather volumes (starting from dimension zero), and the Chern-Mather class of XA. This option is accessed by specifying Output=>HashTable, see the example below. Additional text output may also be requested using the option TextOutput=>"All".


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}} ;




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 package file "EDPolytopeCD2.m2" may be downloaded below:

The Article

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