# Finding integer solutions to $[\sqrt{x^2+y^2}]=k$

I am in the process of trying to devise analytic geometric methods for digital geometry, and came across the following equation:

$[\sqrt{x^2+y^2}]=5$, where $[x]$ denotes conventional rounding.

Apart from (obviously) noting that $0\le x,y\le5$, I let Wolfram Alpha solve this for me and it quickly gave $28$ integer solutions. Turning to the general case, $[\sqrt{x^2+y^2}]=k$, I am wondering if there is a known alternative method to solving for all integer solutions, apart from checking all possible options based on an inequality. I acknowledge it is a quadratic/nonlinear Diophantine equation, but I have never investigated these much before. Thanks!

• You want $20<x^2+y^2<31$. It's not that hard to just count. – Arthur Sep 27 '16 at 21:38
• Good point. Do you think there is a way to generalize the solving procedure? I should have noted that in my original post, and will edit accordingly. – Ethan Hunt Sep 27 '16 at 21:42
• Word descripton would be much more intuitive in this case, you're looking for integer points of a distance from the origin between 4 and a half and 5 and a half units (or less then half a unit distant from a circle of radius 5). – z100 Sep 27 '16 at 21:42
• Seems very close to computer graphics alghoritms (e.g.Bresenham's) for drawing circles, try to find on Stackoverflow. – z100 Sep 27 '16 at 22:03

## 1 Answer

$[\sqrt{x^2 + y^2}] = 5$

$4.5 \le \sqrt{x^2 + y^2} < 5.5$

$21 \le x^2 + y^2 \le 30$

So for $0 \le x \le 5$ we have $21 - x^2 \le y^2 \le 30 - x^2$

So $x= 0; 21 \le y^2 \le 30 \implies (0,5)$

$x = 1; 20 \le y^2 \le 29 \implies (1,5)$

$x = 2; 17 \le y^2 \le 26 \implies (2,5)$

$x = 3; 12 \le y^2 \le 21 \implies (3,4)$

$x = 4; 5 \le y^2 \le 14 \implies (4,3)$

$x = 5; y^2 \le 5 \implies (5,2),(5,1)(5,0)$