Section 3.3 Positive Integer Lattice Points
Question 3.3.1.
Assume there exists a solution (hence infinitely many) to

xxxxxxxxxx
def _(a=slider(1,20,1,1), b=slider(1,20,1,1), c=slider(1,20,1,4)):
ym = c/b + 1
xm = c/a + 1
p = plot(-(a/b)*x+c/b,-1,xm, plot_points = 200)
lattice_pts = [[i,j] for i in [0..xm] for j in [0..ym]]
plot_lattice_pts = points(lattice_pts,rgbcolor=(0,0,0), pointsize=2)
if mod(c,gcd(a,b))==0:
line_pts = [coords for coords in lattice_pts if (coords[0]>0) and (coords[1]>0) and (a*coords[0]+b*coords[1]==c)]
if len(line_pts)==0:
pretty_print(html( 'Solutions to $%sx+%sy=%s$:'%(str(a),str(b),str(c))))
pretty_print(html( 'No positive lattice points at all!'))
show(p+plot_lattice_pts, figsize = [5,5], xmin = 0, xmax = xm, ymin = 0, ymax = ym)
else:
plot_line_pts = points(line_pts, rgbcolor = (0,0,1), pointsize=20)
pretty_print(html('Solutions to $%sx+%sy=%s$:'%(str(a),str(b),str(c))))
pretty_print(html('Number of positive lattice points = ' + str(len(line_pts))))
show(p+plot_lattice_pts+plot_line_pts, figsize = [5,5], xmin = 0, xmax = xm, ymin = 0, ymax = ym)
else:
pretty_print(html('Solutions to $%sx+%sy=%s$:'%(str(a),str(b),str(c))))
pretty_print(html('No positive lattice points at all!'))
show(p+plot_lattice_pts, figsize = [5,5], xmin = 0, xmax = xm, ymin = 0, ymax = ym)
Subsection 3.3.1 Solution ideas
If you think about the question a little more carefully together with the picture, you may realize that we are really asking about how many integer lattice points lie between the intercepts. So one way to think about an answer would involve the distance between solutions. To be concrete, let's assume that the equation isHow many times does that distance fit between the intercepts of the line?
The intercepts are
and respectively.-
Using the Pythagorean Theorem again, we see that the whole length available is
The ratio of this total length and the length between solutions is thus
There is no guarantee that
is an integer! In fact, it usually won't be. For instance, with So should the number of points be bigger than or less than this?Secondly, even so it's not clear what the precise connection between
and the actual number of points is. has one, and has one, but doesn't. Yet is about equal to one for all three of these. In fact, the number of points is thus not even monotone increasing with respect to increasing, which is rather counterintuitive.
Subsection 3.3.2 Toward the full solution
We can deal with each of these problems. To do so, we introduce a new function:Definition 3.3.3. Greatest integer function.
The greatest integer function (also called the floor function) is the function which takes a real number
Example 3.3.4.
A few examples should suffice to understand it:
To take care of the integer problem, we will just consider
the greatest integer function applied toSecondly, we simply recognize that there isn't a nice formula. On average, we should expect
lengths between integer points along the line segment in question (and hence as many as lattice points, since a partition of intervals has endpoints associated to it).
xxxxxxxxxx
def _(c=[5..12]):
a = 2
b = 3
ym = c/b + 1
xm = c/a + 1
p = plot(-(a/b)*x+c/b,-1,xm, plot_points = 200)
lattice_pts = [[i,j] for i in [0..xm] for j in [0..ym]]
plot_lattice_pts = points(lattice_pts,rgbcolor=(0,0,0),pointsize=2)
if mod(c,gcd(a,b))==0:
line_pts = [coords for coords in lattice_pts if (coords[0]>0) and (coords[1]>0) and (a*coords[0]+b*coords[1]==c)]
if len(line_pts)==0:
pretty_print(html('Solutions to $%sx+%sy=%s$:'%(str(a),str(b),str(c))))
pretty_print(html('No positive lattice points at all!'))
show(p+plot_lattice_pts, figsize = [5,5], xmin = 0, xmax = xm, ymin = 0, ymax = ym)
else:
plot_line_pts = points(line_pts, rgbcolor = (0,0,1),pointsize=20)
pretty_print(html('Solutions to $%sx+%sy=%s$:'%(str(a),str(b),str(c))))
pretty_print(html('Number of positive lattice points = ' + str(len(line_pts))))
show(p+plot_lattice_pts+plot_line_pts, figsize = [5,5], xmin = 0, xmax = xm, ymin = 0, ymax = ym)
else:
pretty_print(html('Solutions to $%sx+%sy=%s$:'%(str(a),str(b),str(c))))
pretty_print(html('No positive lattice points at all!'))
show(p+plot_lattice_pts, figsize = [5,5], xmin = 0, xmax = xm, ymin = 0, ymax = ym)
-
The easiest case is when just one of the intercepts is a lattice point. Beginning at that point, there is definitely room for the full
lengths to appear, and you're guaranteed to get lattice points, because we just said the other intercept isn't a lattice point, so the th one must appear before that point. So the formula is just plain oldThis will happen (where
) with (or or ), for instance. If neither
nor is an integer, then you could get or lattice points. There's no nice formula beyond this, and often examples will be like with just one lattice point as βexpectedβ. When the extra point βfitsβ is in examples like the case where we have very close to one, and you do get positive lattice points here.-
Finally, it's also possible for βnot enoughβ lattice points to fit; for example,
jumps back down to points! This situation (not reaching points) can occur when both the - and -intercepts actually are lattice points, because the intercepts by definition do not have positive coordinates. So if and are both integers, then we get preciselylattice points.