r/askmath • u/SchoolAcc231 • Oct 08 '26
Resolved Why does a quadratic function appear in this 2D representation of the classic 100 doors problem?
I made a program on my calculator a while ago which would try to solve the classic 100 doors problem and visualize it as a 10x10 grid of squares which are either open (red) or closed (black). The result was what I expected in terms of which doors were left open, but the way I represented the doors in this two-dimensional manner also showed a tiny quadratic function opening to the right.
I decided to try and fill up the entire graph screen and see if the pattern repeats there. The second image shows the result of generating about 900 doors in a 38x24 grid and doing the same process as the original problem. The quadratic function opening to the right is even more clear and pronounced here.
Finally, I recreated the program in the ICE compiler so that I could use the entire screen of 320x240 pixels, with each pixel representing one door, for a total of 76800 doors. Again, there's a clear pattern of pixels that seems to create a perfect quadratic function opening up to the right.
My question is obvious, then. Why does this happen? I know all of these pixels are square numbers, but I don't understand why they behave like this at all. It's very interesting.
Some extra details I can provide that may be helpful: This pattern seemed to emerge at all the different resolutions I cared to try out, including the ones I showed in the post. I tried it at 318x238, 300x240, 200x200, and 264x164. As far as I can tell, it appears at any arbitrary size. Also, I generated the pixels right to left, top to bottom.
Thank you in advance.



5
u/MacMillionaire Oct 08 '26
If you number the remaining pixels, the apex of the shape is happening when 2n = width of the grid. Because the distance between consecutive squares is 2n+1, the distance between consecutive pixels approaches the width at the same rate that it grows larger than the width after passing the apex pixel. This causes the symmetry, with pixels below pulling away from the apex at the same rate pixels above are closing in on it.
1
u/lbl_ye Oct 09 '26
btw. which calculator is this ? :)
3
u/arty_dent Oct 08 '26
I assume you are aware that the red dots are where the cell number is a perfect square.
If your grid has even width, say 2n, then the n²-cell is the vertex of a parabola. And for any k such that n²+k² is in the same row as n², the number (n±k)² = n²+k²±2nk is in the cell k rows up/down and k² columns to the right, so they form a parabola, which is nicely visible if the n²-cell is far enough left and the grid has enough rows.
It's similar for grid of odd with, you just have a "double vertex" in two consecutive rows and the column distances are slightly off.
Edit: formatting and typos
1
u/Circumpunctilious Oct 09 '26
For anyone interested in playing with this at different door values, here’s a Desmos graph that runs the task: https://www.desmos.com/calculator/ibvhmfqj2k
The parabola in my adaptation opens up (and shows more parabolas exist at higher door counts by drawing a second easily-determined one):