# Numerical coincidence?

(Nobody's answered this one on stackexchange after several days.)

My brother built a garage whose horizontal cross-section is a rectangle that measures $45$ feet by $30$ feet. To make sure the right angles were accurate, he measured the two diagonals of the rectangle to see that they were equal. In inches, $$\sqrt{540^2+360^2} \approx 648.999229548\text{ inches} = 54\text{ feet}+1\text{ inch} - \text{less than 0.001 inches}.$$ It's a bit odd to come within a thousandth of an inch when rounding to the nearest inch, but there's more: The rounding error is about $1/1298$ inches. But $1298$ is of course not exact; it's $$1298+\frac{1}{24073+\text{fraction}}.$$ Coming within $1/24074$ units when rounding to the nearest unit is even rarer.

$1298\cdot24073>31\text{ million}.$ At that rate you can win lotteries.

(I found that $540^2+360^2 + 1^2 = 649^2$.)

Is this merely a case of an archangel descending from the supernatural realm to have some fun messing with our brains, or is something remarkable happening? Or more prosaically, can something intelligent be said about this or is that the whole story?

-
It must be this question (just for reference): math.stackexchange.com/questions/396761/… – András Bátkai May 26 '13 at 17:44
If you bother to compute the continued fraction of $\sqrt{13}$, which is $3,[1,1,1,1,6]$ you'll see that 649/180 is quite a special number. Given that $6$ is one half of $12$ and that we have 12 inches in a foot, you can unravel the rest of this miracle. So, your chance was really just 1/200 or so, just within normal limits of human luck. :) – fedja May 26 '13 at 17:46
@fedja : Maybe you should make this an answer. – Michael Hardy May 26 '13 at 18:11
How about a garage that's $36$ feet by $57$ feet? I found this by searching down a table of integer factorizations starting at $1000$ until I found a pair of consecutive even numbers -- in this case $810=2\cdot3^4\cdot5$ and $808=2^3\cdot101$ -- for which one was divisible by $8$, one by an even power of $3$, and all other prime factors congruent to $3$ mod $4$ appear with an even power. Elsewhere on the list, you run into the pair $650=2\cdot5^2\cdot13$ and $648=2^4\cdot3^4$. – Barry Cipra May 26 '13 at 19:34
@Michael, I think your $24073$ is wrong. I get $$\sqrt{540^2+360^2}=\sqrt{648\cdot650}\approx 649-{1\over1298-{1\over1298+{\text {fraction}}}}$$ – Barry Cipra May 26 '13 at 20:34

I'm going to put my comments into an answer. The first thing to note is that $\sqrt{x^2-1}$, written as a negative continued fraction, has a simple form:

$$\sqrt{x^2-1} = x - \cfrac{1}{2x-\cfrac{1}{2x-\cfrac{1}{2x-\cfrac{1}{\ldots}}}}$$

so I'm not sure where the OP got the number $24073$. The significance of $\sqrt{x^2-1}$ for the problem is, as the OP observed, the fact that $540^2+360^2 = 649^2-1$. What seems to be going on is that $649^2-1=(649-1)(649+1)=648\cdot650=(2^4\cdot3^4)(2\cdot5^2\cdot13)=12^2\cdot3^2(5^2\cdot13)$, where the $5^2\cdot13$, being a product of primes not congruent to $3$ mod $4$, can be written (in various ways) as the sum of two squares.

What's important is that from two consecutive even numbers ($648$ and $650$) we got a factor of $12^2$ to come out (which converts square feet to square inches), and any remaining primes congruent to $3$ mod $4$ (in this case, just $3$) are raised to an even power. As I remarked in comments, $808=2^3\cdot101$ and $810=2\cdot3^4\cdot5$ is another such pair. I found a few others in a table of factorizations up to $1000$, and I would imagine there are more beyond $1000$. Perhaps a good question is whether there are infinitely many such pairs.

-

This probably falls short of answering the question of why a freaky coincidence happens, but at another level it explains it. As I said in comments, the stupid calculator I was using gave me that result repeatedly; now the other stupid calculator I'm using is giving me what Barry Cipra got. Since $540^2+360^2+1^2=649^2$, we have $\sqrt{540^2+360^2} = \sqrt{649^2-1}$, and notice that since $2\cdot649=1298$, we get that $$-649+\sqrt{649^2-1}=\frac{-1298+\sqrt{1298^2-4}}{2}\tag{1}$$ is a solution to $$x^2+1298x+1=0.$$ Rearrange the quadratic equation: $$x = \frac{-1}{1298+x}$$ and then substituting the expression on the right for $x$ within that very expression gives us $$x=\cfrac{-1}{1298-\cfrac{1}{1298-\cfrac{1}{1298-\cfrac{1}{1298-\cdots\cdots\cdots}}}}$$ and from $(1)$ we have $$\sqrt{649^2-1} = 649+x.$$ That's ONE WAY OF LOOKING AT IT, and at one level it explains it and at another it doesn't. But it proves that this expansion is right. I'll look at that dumb calculator again.

-
@Michael, I was composing my answer when you posted yours. I'm glad we agree on the correct continued fraction! – Barry Cipra May 26 '13 at 22:13