# XKCD 356 puzzle

I was reading XKCD and saw this comic:

Turns out it works, and have been thinking about this for an hour and have gotten nowhere.

My first thought was to find the resistance of all paths of length three between the two points, which yields a resistance of 1 ohm, as 1/(1/3 + 1/3 + 1/3) = 1, but that does not factor in the rest of the grid.

Does anyone know how to solve this?

• It's an infinite series problem but I couldn't repeat it. It shows up quite readily on Google with "infinite resistor grid". mathpages.com/home/kmath668/kmath668.htm Commented May 12, 2022 at 22:00
• I think you need PDE's with boundary conditions to solve this, few EE's deal with PDE's Commented May 12, 2022 at 22:21
• Jsotla? What was the point of that edit? Commented May 12, 2022 at 23:41
• Duplicate of question on SE Physics with very detailed answers. physics.stackexchange.com/questions/2072/… Commented May 13, 2022 at 0:23
• @Electron-Capture Do you need a different kind of answer than you have? It may help a little if you say something about what you see and what more you may need to hear.
– jonk
Commented May 16, 2022 at 6:15

## 1 Answer

As DKNguyen mentioned, this mathpages site covers it. This mathpages site also covers the topic.

In the above links, you can find this picture:

So you can just pick out the right answer from there.

Voltage Spike also points out that you can set this up as a grid of PDEs. And doing so allows you to easily solve problems that seek to find the resistance between different placements of the probes, too. (In fact, the entire idea is very powerful and can be used to solve a wide array of problems from heat flow to antennas to charge distribution over complex structures.)

There are a number of numerical approximation techniques for this kind of problem. These include Jacobi and Gauss-Seidel. But another technique found in the literature is called the red-black successive over-relaxation method. I just call it the checkerboard method because that's what it looks like.

Let's say you set up a square checkerboard matrix like this:

But with a much larger grid than that if you want better precision. The INF around the perimeter just means I won't allow the solver to work those squares. Nothing more.

Now you can set up the PDEs. Based upon KCL, it's just $$\V_{i,j}=\frac14\left(V_{i-1,j}+V_{i+1,j}+V_{i,j-1}+V_{i,j+1}\right)\$$

You can look at this link for a run. The results are $$\0.773001\$$ when the exact answer is $$\\frac4{\pi}-\frac12\approx 0.77324\$$. Which is close enough.

You can stack checkerboards to solve 3D problems. Or turn any arbitrary, constrained shape (like a cup or some crazy-looking antenna) and all this still works fine if a sufficiently fine grain grid is chosen. And you can choose to tessellate using something other than squares, too, if that helps simplify the PDE or otherwise tickle your fancy.

And because of how this alternates between red and black square processing, it lends well to a high degree of trivial parallelization. Even 'transputer-like' distributed memory MIMD fits well. F# would also be a good language fit for this.

• I'd have to say that you should lead with the exact answer, rather than ending with it. Commented May 13, 2022 at 11:00
• @WhatRoughBeast I do lead with the exact answer. It's right there in the first image and trivial to find. I may have assumed too much of readers, that they may be able to see the obvious. But I did lead with the exact answer in posting that image where I did post it and with the added comment placed directly below it.
– jonk
Commented May 13, 2022 at 15:45
• Hah, I recall an old Don Lancaster article introducing that method. Let's see, ah here it is: tinaja.com/glib/funfield.pdf Don's old website still going strong! Commented May 14, 2022 at 7:49
• @TimWilliams Thanks for that. Although I have some of his books and have enjoyed them, as well as having had a couple of telephone conversations with him some time back, I've never come across or read that particular PDF. I will find some time, now. Appreciated!!
– jonk
Commented May 14, 2022 at 8:25