Given the equation of a line, we need to find a point with positive integer coordinates$^*$ such that the distance of that point from the line is a minimum.
How can we go about it?
$^*$ i.e. both the $x$ and $y$ coordinates are positive integers
Given the equation of a line, we need to find a point with positive integer coordinates$^*$ such that the distance of that point from the line is a minimum.
How can we go about it?
$^*$ i.e. both the $x$ and $y$ coordinates are positive integers
Copyright © 2021 JogjaFile Inc.
If the slope is irrational and the line does not go through integer points, you can't. There will be integer points arbitrarily close to the line. If the slope is rational, the distances will repeat with period the denominator of the slope. If the slope is less than $1$ in absolute value, you can look at its inverse by making $x$ a function of $y$ and the repeat will be shorter.