PolyhedralSets
NumberOfIntegerPoints
returns the number of integer points of a polyhedron
Calling Sequence
Parameters
Description
Examples
References
Compatibility
NumberOfIntegerPoints(P)
NumberOfIntegerPoints(PP,Vars, Params, opt)
P
-
PolyhedralSet
PP
list(relation)
Vars
list(name)
Params
opt
(optional) equation of the form output = o, where o is either list or piecewise, and/or the keyword compactdisplay
The command NumberOfIntegerPoints(P) returns the number of integer points of P, if P is bounded.
The command NumberOfIntegerPoints(PP,Vars,Params) returns the number of integer points of the parametric polyhedral set PP, with variables in Vars and parameters in Params, if PP is bounded.
By default, the value that is returned for the second calling sequence is a list of ValuesUnderConstraints objects. Using the ValuesUnderConstraints:-Eval command, one can evaluate this list to a list of sets of values, when specializing the parameters to a particular point. If you pass the output = piecewise option, then the output is a piecewise expression. This piecewise expression evaluates to a set of values, when specializing the parameters to a particular point. You can explicitly request the default output by passing the output = list option. In some circumstances (e.g. if there aren't any parameters), the ValuesUnderConstraints objects or piecewise expressions will be fully evaluated to a list of a set of a single integer (with output = list) or a set of a single integer (with output = piecewise).
The constraints in either the ValuesUnderConstraints objects or the piecewise expressions are systems of linear equations and non-strict linear inequalities in the parameters, while the values are polynomials or quasipolynomials in the parameters. A quasipolynomial is an object that assumes the value of one of several polynomials depending on the value of a parameter modulo an integer. The quasipolynomials will also evaluate to concrete values when one applies ValuesUnderConstraints:-Eval.
By default, any quasipolynomials are displayed in a format that explains to some extent what they represent. In some circumstances it may be better to show the quasipolynomials in a more compact way. This can be selected by using the compactdisplay option.
Assumptions
The list PP is a list of linear equations and non-strict linear inequalities
Each indeterminate of each constraint in PP belongs either to the list of variables Vars or to the list of parameters Params.
with⁡PolyhedralSets:with⁡ExampleSets:with⁡ValuesUnderConstraints:
Define a polyhedron
ps≔Tetrahedron⁡;PolyhedralSets:-Plot⁡ps
ps≔{Coordinates:x1,x2,x3Relations:−x1−x2−x3≤1,−x1+x2+x3≤1,x1−x2+x3≤1,x1+x2−x3≤1
Compute its generating function
gps≔GeneratingFunction⁡ps
gps≔x12⁢x22⁢x32+x12⁢x2⁢x3+x3⁢x1⁢x22+x2⁢x1⁢x32+x1⁢x2⁢x3+x12+x1⁢x2+x1⁢x3+x22+x2⁢x3+x32x1⁢x2⁢x3
Compute the number of integer points of ps, which is calculated by evaluating all variables of gps to 1.
NumberOfIntegerPoints⁡ps
11
Define another polyhedron
ps≔TruncatedOctahedron⁡;PolyhedralSets:-Plot⁡ps
ps≔{Coordinates:x1,x2,x3Relations:−x3≤1,x3≤1,−x2≤1,x2≤1,−x1−x2−x3≤32,−x2+x3−x1≤32,−x1≤1,−x3+x2−x1≤32,−x1+x2+x3≤32,x1−x3−x2≤32, and 4 more constraints
gps≔x2⁢x3⁢x12+x22⁢x1⁢x3+x32⁢x1⁢x2+x2⁢x1⁢x3+x1⁢x2+x1⁢x3+x2⁢x3x2⁢x1⁢x3
Compute the number of integer points of ps
7
Compute the number of integer points of a parametric polyhedron (in the parameter n).
NumberOfIntegerPoints⁡1≤i,1≤j,i≤n,j≤n,i,j,n
value n2 when 0≤−2+n,value 1 when n−1=0
We can view the same result as a piecewise expression.
NumberOfIntegerPoints⁡1≤i,1≤j,i≤n,j≤n,i,j,n,output=piecewise
n20≤−2+n1n−1=0
NumberOfIntegerPoints⁡−i≤−1,i≤n,−j≤−1,j−i≤0,i,j,n,output=piecewise
12⁢n2+12⁢n0≤−2+n1n−1=0
Compute the number of integer points of a parametric polyhedron (in the parameter n and m) and pretty-print the result
NumberOfIntegerPoints⁡1≤i,j≤n,i≤m,3⁢i≤5⁢j,i,j,m,n,output=piecewise
one of the polynomials 00−25−15−25 depending on the value of m modulo 5+n⁢m−3⁢m210+3⁢m100≤m−2∧0≤5⁢n−7∧0≤5⁢n−3⁢m−1nm−1=0∧0≤5⁢n−4one of the polynomials 0−13−13 depending on the value of n modulo 3+5⁢n26+n23⁢m−5⁢n=0∧0≤5⁢n−4one of the polynomials 0−13−13 depending on the value of n modulo 3+5⁢n26+n20≤5⁢n−4∧0≤−5⁢n+3⁢m−1
We can display the quasipolynomials in a more compact manner as follows.
NumberOfIntegerPoints⁡1≤i,j≤n,i≤m,3⁢i≤5⁢j,i,j,m,n,output=piecewise,compactdisplay
n⁢m−3⁢m210+QuasiPolynomial0,0,−25,−15,−25,m,5+3⁢m100≤m−2∧0≤5⁢n−7∧0≤5⁢n−3⁢m−1nm−1=0∧0≤5⁢n−4QuasiPolynomial0,−13,−13,n,3+5⁢n26+n23⁢m−5⁢n=0∧0≤5⁢n−4QuasiPolynomial0,−13,−13,n,3+5⁢n26+n20≤5⁢n−4∧0≤−5⁢n+3⁢m−1
Compute the number of integer points of a parametric polyhedron (in the parameter n, m and p) and pretty-print the result
NumberOfIntegerPoints⁡1≤i,i≤n,i≤m,1≤j,j≤p,i,j,m,n,p,output=piecewise
p⁢nm−n=0∧0≤−2+n∧0≤−2+ppm−1=0∧n−1=0∧0≤−2+pnp−1=0∧m−n=0∧0≤−2+n1m−1=0∧n−1=0∧p−1=0p⁢n0≤−2+n∧0≤−2+p∧0≤m−n−1pn−1=0∧0≤−2+p∧0≤m−2np−1=0∧0≤−2+n∧0≤m−n−11n−1=0∧p−1=0∧0≤m−2p⁢m0≤−2+p∧0≤m−2∧0≤n−3∧0≤−m+n−1pm−1=0∧0≤−2+n∧0≤−2+pmp−1=0∧0≤m−2∧0≤n−3∧0≤−m+n−11m−1=0∧p−1=0∧0≤−2+n
The following example shows that the polyhedral set must be bounded, even in the parametric case. Otherwise, an error message is generated.
NumberOfIntegerPoints⁡1≤i,i≤n,1≤j,i,j,n
Error, (in PolyhedralSets:-NumberOfIntegerPoints) polyhedral set must be bounded
Rui-Juan Jing, Yuzhuo Lei, Christopher F. S. Maligec, Marc Moreno Maza: " Counting the Integer Points of Parametric Polytopes: A Maple Implementation." Proceedings of Computer Algebra in Scientific Computing - 26th International Workshop (CASC) 2024: 140-160, Lecture Notes in Computer Science, vol. 14938, Springer. ##
The PolyhedralSets[NumberOfIntegerPoints] command was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
PolyhedralSets[NumberOfIntegerPoints]
PolyhedralSets[GeneratingFunction]
PolyhedralSets[ZPolyhedralSets]
PolyhedralSets[IntegerHull]
Download Help Document