I have two rational points. They are denoted below in black and they define a line segment. Find integer points on this segment.
a = {45/2, 0}; b = {45/3, -45/3};
Plot[2*x - 45, {x, 0, 23}, GridLines -> {Range[23], -Range[30]},
AspectRatio -> 1, PlotRange -> {{0, 23}, {-23, 0}},
Epilog -> {PointSize[Large], Point[{a, b}], Red, PointSize[Medium],
Point[Table[{i, 2*i - 45}, {i, 15, 22}]]
}]
It happens that I know the solutions, and they are denoted as red dots. The question is how to get them programmatically, not only in this but in all cases, for instance a = {21, 0}; b = {21, 10/5}
.
Notice that unlike this post, i) the given points are rational, and ii) all solutions are required, not just positive.
FindInstance
,Reduce
andSolve
all work as expected:Solve[2*x - 45 == y && x >= b[[1]] && x <= a[[1]], {x, y}, Integers]
. $\endgroup$x > 0 && y > 0
since the OP wanted to find coordinates (which) are positive integer. You don't have this condition, so you have to restrict the coordinates to your bounds. $\endgroup$