# How to print all the integer points on and inside the graph of the equation?

Consider an equation $(x-1)^2/25+(y+2)^2/9=1$.

(x-1)^2/25+(y+2)^2/9==1


How can one print all the integer points on and inside the graph of the equation?

I tried many times but failed to solve it.

• There are things to do after your question is answered. It's a good idea to stay vigilant for some time, better approaches may come later improving over previous replies. Experienced users may point alternatives, caveats or limitations. New users should test answers before voting and wait 24 hours before accepting the best one. Participation is essential for the site, please do your part. Jul 1, 2018 at 8:31

This Prints the numbers, as you asked.

Module[
{
eqn = (x - 1)^2/25 + (y + 2)^2/9 <= 1,
region,
pnts
},
region = ImplicitRegion[eqn, {x, y}];
pnts = ({x, y} /. Solve[{x, y} \[Element] region, Integers]);
Print[pnts];
]

{{-4,-2},{-3,-3},{-3,-2},{-3,-1},{-2,-4},{-2,-3},{-2,-2},{-2,-1},{-2,0},{-1,-4},{-1,-3},{-1,-2},{-1,-1},{-1,0},{0,-4},{0,-3},{0,-2},{0,-1},{0,0},{1,-5},{1,-4},{1,-3},{1,-2},{1,-1},{1,0},{1,1},{2,-4},{2,-3},{2,-2},{2,-1},{2,0},{3,-4},{3,-3},{3,-2},{3,-1},{3,0},{4,-4},{4,-3},{4,-2},{4,-1},{4,0},{5,-3},{5,-2},{5,-1},{6,-2}
}


But probably you actually want to do something with them, not just Print them.

Module[
{
eqn = (x - 1)^2/25 + (y + 2)^2/9 <= 1,
region, pnts
},
region = ImplicitRegion[eqn, {x, y}];
pnts = ({x, y} /. Solve[{x, y} \[Element] region, Integers]);
Show[
Region[region],
ListPlot[
pnts
, PlotStyle -> Red
, PlotTheme -> "Scientific"]

]
]


• @Alan thanks for checking and warning me. I had two versions, and pasted the wrong one. It's fixed now. Jul 1, 2018 at 8:31
sol=NSolve[(x - 1)^2/25 + (y + 2)^2/9 <=  1, {x, y}, Integers]
Show[{ RegionPlot[(x - 1)^2/25 + (y + 2)^2/9 <= 1, {x, -5, 7}, {y, -6,2}],ListPlot[{x, y} /. sol]}, PlotRange -> All,AspectRatio -> Automatic]


solves the problem!

• To answer the question as stated, I think you need to change == to <= Jun 28, 2018 at 19:37
• Thanks, I edited my answer. Jun 29, 2018 at 6:37
• @UlrichNeumann you should have plotted the ellipse for completeness, +1 Jun 29, 2018 at 10:12
• @José Antonio Díaz Navas: Done, thanks. Jun 29, 2018 at 10:33
reg = Region @ ImplicitRegion[(x - 1)^2 / 25 + (y + 2)^2 / 9 <= 1, {x, y}];
lattice = Tuples[Range[Ceiling @ #, Floor @ #2]& @@@ RegionBounds[reg]];

Show[reg, RegionIntersection[reg, Point @ lattice]]


Show[reg, Graphics@{Red, PointSize @ Large, Point @ Select[lattice, RegionMember[reg]]}]


coords = Pick[lattice , RegionMember[reg, lattice]]


{{-4, -2}, {-3, -3}, {-3, -2}, {-3, -1}, {-2, -4}, {-2, -3}, {-2, -2}, {-2, -1}, {-2, 0}, {-1, -4}, {-1, -3}, {-1, -2}, {-1, -1}, {-1,   0}, {0, -4}, {0, -3}, {0, -2}, {0, -1}, {0,   0}, {1, -5}, {1, -4}, {1, -3}, {1, -2}, {1, -1}, {1, 0}, {1,   1}, {2, -4}, {2, -3}, {2, -2}, {2, -1}, {2,   0}, {3, -4}, {3, -3}, {3, -2}, {3, -1}, {3,   0}, {4, -4}, {4, -3}, {4, -2}, {4, -1}, {4,   0}, {5, -3}, {5, -2}, {5, -1}, {6, -2}}

If you stick to graphics primitives, than you can just use RegionIntersection. For example, the disk is:

disk = Disk[{1,-2}, {5,3}];


and a lattice that encompasses the disk is:

lattice = Point @ Tuples @ Replace[
CoordinateBounds[disk],
{a_, b_} :> Range[Floor[a], Ceiling[b]],
{1}
];


The intersection is then:

inter = RegionIntersection[disk, lattice]


Point[{{-4, -2}, {-3, -3}, {-3, -2}, {-3, -1}, {-2, -4}, {-2, -3}, {-2, -2}, {-2, -1}, {-2, 0}, {-1, -4}, {-1, -3}, {-1, -2}, {-1, -1}, {-1, 0}, {0, -4}, {0, -3}, {0, -2}, {0, -1}, {0, 0}, {1, -5}, {1, -4}, {1, -3}, {1, -2}, {1, -1}, {1, 0}, {1, 1}, {2, -4}, {2, -3}, {2, -2}, {2, -1}, {2, 0}, {3, -4}, {3, -3}, {3, -2}, {3, -1}, {3, 0}, {4, -4}, {4, -3}, {4, -2}, {4, -1}, {4, 0}, {5, -3}, {5, -2}, {5, -1}, {6, -2}}]

Visualization:

Graphics[{FaceForm[LightBlue], disk, Black, lattice, Red, inter}]