Monday, April 5, 2021

x ^ y % 9

https://twitter.com/aemkei/status/1378106731386040322 shows a really interesting graphic generated using a simple rule: ((x ^ y) % 9) != 0. I was curious what it would take to reproduce this in Autoplot, a data browser/analysis system developed by my brother and others. Based on an example script from him, the following seems to work:
x = outerProduct(linspace(0, 255, 256), ones(256))
plot(gt(bitwiseXor(x, transpose(x))  % 9, zeros(256, 256)))
I'm pretty happy with how it turned out. I don't have time now to dig into what's going on with the image much now, but zooming in on one corner may help:
def xorModPlot(n=256, modulus=9):
  x = outerProduct(linspace(0, n - 1, n), ones(n))
  plot(gt(bitwiseXor(x, transpose(x))  % modulus, zeros(n, n)))

xorModPlot(n=32)
The 45 degree diagonal line makes sense since any integer XOR-ed with itself = 0. I was going to say that this raises another question, how much is accounted for the XOR operation alone. But, naturally, for any x != y, they differ in at least one bit and so x ^ y != 0 in that case. Notes:
  • To get the script editor, remember to select "Script Panel" under the "Enable Feature" menu under "Options".
  • You can find a download link for the Mac version of Autoplot on http://autoplot.org/latest/
  • To get a black and white image, under the "style" panel, I selected Colortable: "grayscale" and Rebin: "noInterpolate".

No comments: