How this calculation works
Ehrhart counting tracks lattice points in every nonnegative integer dilation of an integral polygon. This calculator computes the exact quadratic counting polynomial from area and boundary lattice count, evaluates a chosen dilation and uses interior reciprocity for positive dilations. It is a family of counts, rather than only one polygon-area calculation.
L_P(t)=area(P)t²+(boundary(P)/2)t+1; interior(t)=area(P)t²−(boundary(P)/2)t+1.A worked example
The unit square has area one and four boundary lattice steps. Its polynomial is t²+2t+1=(t+1)². At t=3, the closed square contains 16 lattice points and its strict interior contains four. At t=0, the closed polygon collapses to one lattice point.
Good to know
Integral simple polygons without holes, coordinates within ±1,000,000 and dilation zero through 1,000,000. Exact area/count arithmetic follows numerical simple-polygon validation. No rational-polygon quasipolynomial or higher-dimensional Ehrhart claim.
Reference: Sage lattice polytope Ehrhart polynomials (opens in a new tab) ↗
Integer dilations define the counting family
A dilation multiplies every polygon coordinate by the same nonnegative integer t about the origin. Translation by an integer vector does not change the lattice count, while a noninteger translation can. Integral vertices are required for this polynomial formula; rational vertices can instead produce a quasipolynomial with periodically varying coefficients.
The polygon boundary must be a simple ordered loop without holes. Reordering an arbitrary point cloud into a different polygon would change its area and boundary lattice structure, so the calculator validates the supplied geometry rather than taking a convex hull or guessing how the points should be connected.
The Lattice polygon area by Pick’s theorem calculator covers the nearby task. Pick area is a single-shape invariant; Ehrhart evaluates all integer dilations and interior-count reciprocity.
Boundary steps determine the linear coefficient
The quadratic coefficient is the exact polygon area. The linear coefficient is half the boundary lattice-step count, obtained by summing gcd values along edges. This avoids explicitly visiting every boundary point and remains exact even for long oblique lattice edges whose endpoints have large integer coordinates.
Combining those coefficients with constant one gives the closed-polygon count at every supported integer dilation. The result should be integral even when the area or boundary-half coefficient is fractional. Exact parity checks provide a useful certificate that the lattice geometry and formula have been combined consistently.
Interior reciprocity needs a positive dilation
For positive t, changing the sign of the linear term gives the strict-interior count. At t=0, the closed polygon collapses to one lattice point and the ordinary interior interpretation needs separate treatment. The page therefore leaves the interior reciprocity output undefined at zero rather than displaying the polynomial constant as a physical interior point.
Unit squares, lattice triangles and translated shapes provide independent enumeration checks for several dilations. These tests distinguish the family-count task from Pick’s theorem applied to one shape. No hole correction, rational-polytope period, three-dimensional Ehrhart coefficient or unlimited-coordinate geometric-validation guarantee is claimed by the bounded two-dimensional implementation.
Derive the two-dimensional lattice-count polynomial
For an integral simple polygon without holes, let A be area and B the number of lattice boundary steps. Pick’s theorem gives I=A−B/2+1 for strict interior points. Under positive integer dilation t, area becomes At² and boundary count becomes Bt, giving closed count L(t)=At²+(B/2)t+1.
The corresponding strict interior count is At²−(B/2)t+1 for t>0. The sign reversal in the linear term is the two-dimensional reciprocity pattern. These formulas count lattice points on and inside the geometric dilation, not cells, triangulation vertices or arbitrary sample points drawn by the illustration.
Count a dilated right triangle by hand
Use vertices (0,0),(2,0),(0,1). Area is one. Edge boundary contributions are gcd(2,0)=2, gcd(2,1)=1 and gcd(0,1)=1, giving B=4. Hence L(t)=t²+2t+1=(t+1)² and the strict interior count is (t−1)² for positive t.
At t=2, the dilated vertices are (0,0),(4,0),(0,2). Its horizontal rows contain five points at y=0, three at y=1 and one at y=2, totaling nine. Only (1,1) is strictly interior. This enumeration verifies both closed count nine and interior count one without relying on the polynomial alone.
Use edge gcds rather than just counting vertices
A segment with integer displacement (dx,dy) contains gcd(|dx|,|dy|)+1 lattice points including both endpoints. Summing the gcd contributions around the polygon counts each boundary lattice point once, whereas summing the endpoint-inclusive segment counts would double-count vertices. A long horizontal edge can contribute many boundary points beyond its endpoints.
The shoelace formula computes exact doubled area from integral coordinates. The result can be a half-integer, and B can be odd; the final polynomial nevertheless returns integers at nonnegative integer t. Exact arithmetic checks that parity. Do not round the area before evaluating the lattice count.
Respect topology and the special zero dilation
At t=0 the polygon collapses to the origin and the closed count is one. The positive-dilation strict-interior formula is not interpreted as an interior count of that collapsed set; the interface labels that case separately. For t>0, integer translation and reversing the vertex orientation preserve counts.
Vertices must follow a simple boundary with no self-intersections and no holes. A crossing shoelace path does not define the same filled region, and a rational-vertex polygon generally needs a quasipolynomial rather than this integral formula. Numerical topology validation precedes exact area arithmetic, so the certificate is conditional on the accepted simple-polygon model, not a general polygon-arrangement engine.
A few questions, answered
Can I use rational polygon vertices?
No. This polynomial form requires integral vertices; rational polygons generally need quasipolynomials.
What happens at dilation zero?
The closed count is one; strict-interior reciprocity is not asserted there.
Is B just the number of supplied vertices?
No. It is the sum of gcd(|dx|,|dy|) along all edges and includes lattice points between vertices.
Why is the interior result special at dilation zero?
The polygon collapses to one point. Positive-dilation interior reciprocity is not used as an interior count for that collapsed object.