## Aztec diamonds: Testing the reversed Aztec numbers

,My initial test of *x*=ceil(sqrt(2*y*)/2) to determine the size of a square given a value in A046092 corresponding to how many line segments would remain if the grid formed internally at every unit of height and width of the square was broken at every intersection was tested and shown to be valid for the first 1000 numbers in the sequence. I did this haphazardly in Excel, just to make sure it wasn’t going to fail quickly.

I have since scripted a test in python, which has thus far shown my method viable up to a 50907428697×50907428697 square. The script is called by passing it an argument containing the initial integer for the square’s size (default 2), and it loops infinitely until it either fails or is halted with SIGINT. Upon halting, it returns something like `Last success: Square 39033633; azNum 3047249088424644; urNum 39033633.0`

, where `Square`

is the height/width of the square being tested, `azNum`

is the number of line segments (or squares in the equivalent Aztec diamond), and `urNum`

is the calculation which (hopefully) is equal to `Square`

. Revealing the last success in this way tells me where to start next time. The code:

```
import signal
import sys
from math import ceil,sqrt
def sigintHdl(signal,f):
print "Last success: Square %s; azNum %s; urNum %s" % (tNum-1,azNum,urNum)
sys.exit(0)
signal.signal(signal.SIGINT,sigintHdl)
tNum = 2 if len(sys.argv)<2 or int(sys.argv[1])<2 else int(sys.argv[1])
result=0
while result==0:
azNum=tNum**2+tNum*(tNum-2)
urNum=ceil(((2*azNum)**.5)/2)
result=urNum-tNum
tNum+=1
print "FAILURE: Square %s; azNum %s; urNum %s" % (tNum-1,azNum,urNum)
```

There’s another way of looking at this whole thing. If we consider an isosceles right triangle with hypotenuse *h*, we know the length of either of the legs is equal to sqrt(*h*^2/2). Interestingly enough, if we work with a hypotenuse of one unit larger (which should never exist as a halved Aztec diamond), *h*^2/2 is equal to our A046092 value +0.5.

Ultimately, the problem seems to be one of dealing with a not-quite-proper triangle. It’s easy to imagine additional nodes that make the triangle more… triangular. Doing so leads to more funny math, but it all sort of, kind of makes sense. I guarantee there’s an off-the-shelf solution out there, and it’s likely quite straightforward and, in hindsight, obvious. But this sort of math isn’t necessarily my forté, so I’ll just fidget around until I come up with something conclusive. At this point, it’s all for fun – I have far more known-valid values than I could ever imagine needing. My little python test snippet will easily be reused for other things as well, so I’ll call that a win.