There Are Magic Hexagons of Every Order

(gukov.dev)

146 points | by gukoff 10 hours ago ago

20 comments

  • yunruse 6 hours ago ago

    I loved this article and its interactive elements. The potential field is an elegant abstraction which really elevates this from a math puzzle into something new.

    I'd love to see just how Lipschitz continuous, how smooth, the potential field can be; how adding features puts it closer to or further from solutions that fit the consecutive-no-duplicate constraint, say. Adding a smooth 'hill' is probably viable; is a 'river'?

    One little critique I have is in the latter third. Using LLMs for proof is pretty standard now, but the way the text focuses on their tribulations was distracting. It might have been cleaner to use the mathematician's "we" after introducing the 'co-authors', so that the casual reader might sink their teeth into the math rather than be reminded LLMs can sometimes cost money and go around in loops.

    But otherwise this is a really gorgeous article! The visualisation is really powerful, and something about how the symmetries impose a kind of conservation (which looks like hot soup but actually has a smooth potential) are very exciting, and curiously very physicsy.

    • gukoff 4 hours ago ago

      Thanks a lot for the detailed perspective!

      The potential fields are a curious phenomenon. I feel like - and I haven't verified this in any way yet - the smoothness is dictated by the fact that all values are within a not-so-broad range. Then as you "peel" the hexagon from the outer layer using those 6-rings, building the potential field, each next layer inwards shouldn't changed too much.

      I had also explored a case of n->inf where the sums turn into integrals, and consecutiveness turns into the uniform distribution. Then it's not so hard to find a solution. It's not in the article, because it turned out to be a dead end for solving the discrete case, and I didn't want to make the article too heavy - but if I remember correctly, there I also observed the smoothness.

      • amluto 20 minutes ago ago

        Can you clarify what the “potential field” actually is? The text is not really precise, and the little interactive tool has the very curious property that I can set all the potentials to 0 and I don’t get all zeros in the magic hexagon.

        I would guess that the smooth mountain-looking structure come from a very simple observation: a gadget consisting, in potential space, of a 2 surrounded by a ring of 6 1’s fully cancels at the center and in the ring immediately around the center and leaves a nice pattern of +1 and -1 residuals in the ring around it. I suspect that, fairly generally, as you try to build out small numbers around the outside of the magic hexagon, you end up with a large pile of things like this in the center, and a sum, even a very noisy one, of things that even vaguely Gaussians, tends to produce Gaussians. (That’s the central limit theorem.)

  • arjie 4 hours ago ago

    Huh, this potential technique seems fairly neat. Thank you for explaining the whole thing in a fairly accessible way. Enjoyable interactive bits as well. An aside is that the playground looked fine on my iPhone. The anticipatory objection of smallness did not materialize.

    • gukoff 3 hours ago ago

      Thank you, I'm glad you found it readable on mobile!

  • cbondurant 3 hours ago ago

    my immediate first thought is that I've never heard of the consecutive constraint before, or that if I have I have forgotten about it. I've only ever heard of a uniqueness constraint, that no number can be used twice, which still achieves the same goal of preventing filling every cell with exactly one number.

    Then again, I do mostly remember this in terms of the yet unsolved magic-square-of-squares problem, not the standard magic square.

  • unholiness 5 hours ago ago

    Cool problem. I always doing it a bit unsatisfying that magic hexagons so trivially disallowed solutions that aren't order 3. Starting at a different index is a nice modification, especially since for magic squares it's an equally hard problem.

    He says "every order" is solvable this way but I don't think any solution could work for an order 2 hexagon, even without his simplifying constraints (since fixing any side cell to x requires 2 cells to be set to sum-x).

    • gukoff 5 hours ago ago

      You're absolutely right, technically the title should have said "every order other than 2" or "every order larger than 2". The case for 2 is impossible, because it immediately forces equal numbers on the outer layer.

  • amelius 7 hours ago ago

    Why is not every 45 degree line considered for the rectangular grids?

    (In the hexagons, all lines are considered even if they don't have the maximum length)

    (PS: make sure you hover your mouse over the diagrams)

    • gukoff 7 hours ago ago

      Interesting observation. That's simply part of the usual definition of a magic square, and it does indeed feel arbitrary once you compare it with the hexagon case, which is very symmetrical. I first learned about magic squares from math books as a kid, about 25 years ago, and just accepted those rules as given.

      Upon a quick research, there are many variations, and the closest to what you're describing is the "pandiagonal" magic square, where additional diagonals are considered (except they wrap around the edges of the square in a slightly funny way, so that every diagonal still contains exactly N numbers): https://en.wikipedia.org/wiki/Pandiagonal_magic_square

    • Sharlin 7 hours ago ago

      The shortest 45 degree line in a magic square is a single cell, making it somewhat tricky to add up to the same total as the other lines.

    • unholiness 5 hours ago ago

      Why not every line of knights moves too? Because the cells aren't adjacent I'd say. (Both immediately make the problem unsolvable since all corners must match).

      Seems "unfair" that hexagons have multiple line lengths to consider. I think this article's modification is a good one in that framing: Shifting every number up or down doesn't make the magic squares any easier, but it certainly helps with hexagons.

    • layer8 4 hours ago ago

      In the hexagons, 30-degree lines could be considered as well — there might even be solutions when treated analogously to pandiagonal magic squares.

  • reckless 8 hours ago ago

    hexagons are the bestagons

    • DavidPiper 6 hours ago ago

      and hexaflexagons are the bestaflexagons

    • sublinear 8 hours ago ago

      CGP Grey is never coming back

      • chrystalkey 7 hours ago ago

        Right probably. Do you know what happened by any chance?

        • bluedragon1221 7 hours ago ago

          Not sure. He quit his podcast (Cortex) saying it was "time for a break." Now Myke runs the show by himself

        • doctorwho42 6 hours ago ago

          If you were given something like $10mil, invested in index funds over the last 10 years, in nontax advantaged accounts. And your wife has health issues.

          No kids.

          Not to mention, a world where nature is taking a beating year after year.

          Do you think you'd be interested in working in front of a computer day after day researching, script writing, etc. for people you don't know and probably will never meet?

          Now take that answer, and ask yourself - if you were a content generator for your career, and your content got consumed into every AI model early on. Now making any submission have the added hurdle of being content flagged for possible AI usage. Ultimately taking a huge hit to your revenue model...

          Or perhaps, spending your time with your wife. Enjoying nature. And just generally disconnecting from the rat race. Especially the rat race 3.0 (Now with AI!)

          Like yeah, do some projects here and there for yourself. But do you really want the added burden of pleasing others?

          • chrystalkey 6 hours ago ago

            Way over the top mate.

            I was just genuinely asking whether there was some specific reason or he just withdrew himself from the public because life happens.

            No need to get argumentative.