# Resistor Grid Voltages Challenge

Discussion in 'Math' started by MrAl, Apr 29, 2017.

1. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718
Hi,

No i ended up doing the calculation itself i misunderstood at first, however with the next reply i am doing that i think, by computing the integral of 1/k and then showing the difference (dR2 column).
I also did Sum(1/k) and that looks promising.

2. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718

Hi,

Yes, and i did the true calculations knowing some properties about an electric field, but i did not plot the equipotential lines which is a great idea so i'll have to try to get to that too. If we draw a diagonal line along the same two opposite corners that we apply the potentials (10v and 0v) and then a second diagonal from the other two opposite corners, potentials along the first diagonal above the second diagonal are more positive than their neighbors, while below the second diagonal they are less than their neighbors. So along the first diagonal above the second diagonal they curve upward slightly and below that second diagonal they curve downward slightly. So it's like a very wide and stretched out "S" shape, more like a tilde that runs along that first diagonal.

Here are the results of the actual calculation vs the Sum 1/k and the Integral 1/k, both adjusted by a factor of 10 and an offset of 10.

Code (Text):
1.
2.
3. N    R      Sum      dR1     Intg     dR2
4.   1  10.000  20.000  10.000 10.010   0.010
5.  10  31.326  39.290  7.964  33.031   1.705
6.  20  39.543  45.977  6.434  39.962   0.419
7.  30  44.499  49.950  5.451  44.017  -0.482
8.  40  48.057  52.785  4.728  46.894  -1.163
9.  50  50.836  54.992  4.156  49.125  -1.711
10.  60  53.115  56.799  3.684  50.949  -2.166
11.  70  55.048  58.328  3.280  52.490  -2.558
12.  80  56.725  59.655  2.930  53.825  -2.900
13.  90  58.208  60.826  2.618  55.003  -3.205
14. 100  59.535  61.874  2.339  56.057  -3.478
15. 200  68.297  68.780  0.483  62.988  -5.309
16.
17. Columns as follows:
18. N:  number of resistors on one edge of the NxN grid
19. R:  actual calculation of total corner to opposite corner resistance
20. Sum:  Sum of 1/k from 1 to N times 10 with 10 added.  10*Sum(1/k)+10.
21. dR1:  difference, dR1=Sum-R
22. Intg: approximate integral of 1/k from 1 to N times 10 with 10 added.  10*integral(1/k)+10.
23. dR2:  difference, dR2=Intg-R.
24.
25.
26.
27.

3. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718
Hello again,

I cant edit the previous post or the columns will distort again because there is something strange about the 'code' tags on this forum when you go to edit a post it distorts the character spacing. I wanted to include a picture file of the results in case it gets messed up again so here it is...

Here we see some evidence that the values do approach 10*(Sum(1/k)+1) as N increases. The integral (1/k) seems to diverge away from the true solution.

4. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,364
350
Try adding another column after the dR1 column showing the percentage error. You could label it PE1. I calculated it as 100*(Sum-R)/R

Also let the column for N go from 1 to 10 in steps of 1 before you start increasing by 10. This way we can see the behavior in the percentage error around N=7.

5. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718

Hi again,

Ok, here i added columns for fractional percent error of the sum of 1/k and also for the integration of 1/k, but i dont see a change in sign around N=7 it appears higher here with the complete integral though not the sum. This could be because i adjust for N=1 in either calculation. Check it out see what you think.

Here's the new data:

6. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,364
350
I was using 10*Sum(1/k) rather than 10*Sum(1/k)+10 because it gives a better approximation at small N. I was also taking N to be the number of nodes on a side rather than the number of resistors.

Either way, the values derived from the harmonic series is larger than the true value, which would suggest that Req is unbounded.

This is the result for a two-dimensional array of resistors. I wonder what the result for Req between diagonally opposite corners of a cube would be? Would the three-dimensional Req increase without bound as N increases? I'm reminded of the different behavior of a random walk in different dimensions: https://en.wikipedia.org/wiki/Random_walk

I can't do any calculations for a while as I won't have a computer accessible.

7. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718
Hello again,

I included some new results here along with an approximate equipotential plot for a large grid.

Oh ok, well in the next attachment i included calculations for 10*sum(1/k) also for reference.
If you took N to be the number of nodes on one side i dont see how we got the same results for N=20, but if you want to compare to my results after that then just look at N-1 i guess. The number of nodes on one edge for the number of resistors on one edge being N is N-1 nodes.

The new calculations also include N=300 now, which means 180600 resistors are involved and 90601 nodes
What this shows is that the calculation of 10*sum(1/k)+10 gets closer and closer to the real value but then starts to move away from that also, as for N=300 the approximate result with sum(1/k) is too small when for all other values before that it was too large.

I think the cube is different because it is more symmetrical. I'll have to try that next i guess. The square is unsymmetrical because of the edges where a node voltage depends on less other local nodes than in the central regions, and the cube would be unsymmetrical because of the corners which would depend on a lower number of local nodes than in the central edge regions. I would think that the sphere is the most symmetrical which has to be symmetrical everywhere, but then the question arises as to whether we can actually create a sphere with resistors as it would be more like just a multi sided geometric figure. A guess is that we would have to start connecting the resistors in triangle shapes rather than the square shapes being used for the large square grids. That would then be like creating two geodesic domes connected together.

It is starting to look like the Requiv corner to corner increases without bound just like the ln(x) function. If we look at a small section of ln(x) we see that it looks like it is leveling off, but when we zoom out and look over a larger x, we still see the same behavior, so the zoomed in view is just a microcosm of the zoomed out view so that behavior never changes.

In the equipotential graph that follows, the first graph was found on the web with no explanation of what it was, but it looked like what the data suggested for the diamond grid so i rotated it by 45 degrees, then used that to draw the second image by hand. The second image was drawn by hand so the curves are approximate, but they do show the tendency for the lines to become less and less curved as we get closer to the minor diagonal (the minor diagonal goes from the lower left hand corner to the upper right hand corner). I didnt get to plot this based on the node voltage data yet so that's a rough view of the lines. Ignore the 'force' lines and other stuff in the first diagram.

8. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718
Hello again,

Little update...

Two more results are in for the NxN=400x400 grid and the NxN=500x500 grid.

N=400: R=77.091 (320800 resistors, 160801 nodes)
N=500: R=79.92 (501000 resistors, 251001 nodes)

The N=400 value should be accurate, while the N=500 value could be up to about 79.93 and this is because i had to run out in the middle of the calculation so didnt get to finish it yet.

The results show that 10*(sum(1/k)+1) is diverging from the true values more and more, with the difference going more and more negative now when before it was positive.

One other interesting fact that i found was that this kind of problem definitely must have solution that is a solution of some kind to Laplace's Equation:
Del^2*U=0
which in two dimensions comes out to be:
Uxx+Uyy=0

The unofficial proof comes from solving that last equation numerically and obtaining exactly the same values as doing it the longer way using an actual resistor grid, and luckily it is also a faster method. The drawback is that using that method i cant change any of the resistor values to find out what happens with other resistor values in the grid, like say with all resistors 10 ohms except one in the middle somewhere that is 11 ohms. For the "all resistors are equal" solution though it works nicely, which means there is probably an analytical solution to this, and i would not doubt it if someone found it already.

An interesting side fact is that the number of resistors really grows and grows...for N=500 over half a million resistors are involved, and over a quarter million nodes.

Last edited: May 10, 2017
9. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718
Hello again,

I realized that we have two kinds of cubes to consider if we want to do a cube of some kind. The first is a surface cube, the second is a volume cube.
The surface cube would be like welding 6 square sheets of copper at the ends to form a cube which would be an empty box.
The volume cube would be a solid object, like a solid copper cube.
I was actually thinking of doing the solid copper cube.

Also, when i said previously:
"there is probably an analytical solution to this, and i would not doubt it if someone found it already"

that was actually true, and the person that found it happened to be me
I had forgotten about that over the long periods of not doing those kinds of problems. Of course i was not the only one though, there were probably many people that solved it. I'm pretty sure i posted all or part of the solution on the web somewhere too, but exactly where i cant remember either, and with site crashes it could have gotten lost anyway.

Unfortunately i can only remember bits and pieces of how the solution goes. It starts with Laplace's Equation on a continuous sheet, finding the fundamental solutions, then using the boundary conditions to weed out the fundamental solutions, then apply an integral transform that takes us from the continuous domain to the discrete version of the surface, and that's where we get down to the resistor grid and so we can find the voltage at any node through that transform in a single calculation, and that leads to the total resistance. I dont remember much more about this except the boundary conditions are exceptionally easy to handle being simpler in origin than most other problems like this, and whether or not the integral transform requires a numerical integration (which i dont mind if it is necessary). This means of course that there would be no limit to how many resistors we could have on one edge, a million would not be out of the question, which in conventional straightforward nodal circuit analysis would require over 2 trillion resistors and over 1 trillion nodes.

10. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718
Hi,

Little update...

N=700, R=84.20 Ohms.

and again that is with each individual grid resistor equal to 10 ohms each.

A few other things i remembered when working with the admittance matrix, or in this case the conductance matrix...i numbered these things #1, #2, #3, and #4. These all pertain to 64 bit floating point when talking about precision except as noted.

[Idea #1]
First, doing a matrix inverse for the solution with a column vector:
M.v=V

and to solve:
v=(M^-1).V

where v is the solution set.

Well, if we swap two columns we can force the actual single solution we want to appear as the last element in v, so for example if we got results:
v=[1,2,3,4,5]

and before we did the solution we swapped two columns one of which is the variable of interest column, we would get a different order. Say we wanted that '2' only, then we would swap columns and edn up with:
v=[1,5,3,4,2]

and it's clear that the 2 is now the last variable in the solution set. This leads to another method which is faster than inversion, namely, converting the matrix to upper triangular.

We cant convert the original matrix with columns swapped though, we have to swap the columns and then augment the array with the column vector:
M=M aug V

and if we started with a 5x5 matrix now we would have a 5x6 matrix (5 rows, 6 columns), so the matrix is no longer square. However, if we next convert that matrix to upper triangular, we get a simple outcome. We get another full rectangular matrix but the last row is in a form that makes a simple equation that can be solved easily to get that one solution we are after.

For example, if the solution is known to be:
[1,5,3,4,2]

then we would have started with a 5x5 matrix, and after augmenting we would get a 5x6 matrix, then after converting to upper triangular we would get another 5x6 matrix, but the last row of that matrix would be something like this:
[0,0,0,3.2,6.4]

and this represents the simple one variable equation:
3.2*x=6.4

and so the solution is easily obtained:
x=6.4/3.2=2

The reason this is faster is because it eliminates the need for the back substitution step used in a lot of matrix solver algorithms. How much faster depends on how they implemented the algorithm in your software, as well as how they implement the conversion to upper triangular in your software. For mine it is quite a bit faster for very large matrixes, but i did not actually time it.
Note the leading zeros, so if we had a 8x9 matrix we would have gotten:
v=[0,0,0,0,0,0,3.2,6.4] (row vector again)

and so the same solution equation.

[Idea #2]
This is more of an observation. I had not thought about this for a while but when we do a nodal analysis using matrix math, we have one variable per node. So if we have 4 nodes we have 4 variables, but that means a 4x4 matrix, and that means at least 16 objects and in 64 bit floating point that's 128 memory locations in RAM or on hard disk. Not a big deal right? Right, but what happens when we get a large number of nodes.
If we have 10 nodes, we end up with a 10x10 matrix and so 800 mem locations. Still not bad at all.
If we have 100 nodes, we end up with a 100x100 matrix, or 80000 mem locations.

Now let us relate that to the number of resistors on one side of the resistor grid.
With 4 resistors on one side, that's 5 nodes on one side, so that's 25 nodes (minus 2 for Vcc and ground, but lets keep it simple and use 25 for now even though it will actually be 24x24).
So 25 nodes means 25x25 which is 625, and that times 8 comes out to 5000 bytes of memory.
See where this is going now. The mem usage goes up fast.
With 10 resistors on one side, that's 11x11 nodes, or 121 nodes, and so a 14641 element matrix, and so the bytes usage is 117128 bytes, or in terms of memory storage units about 114 kilobytes. Not much on today's computers, but let us keep going...
With 20 resistors on one side, that's 21x21 or about 1.5 megabytes.
The formula is simple of course, in bytes:
Bytes=8*(Nr+1)^4=8*Nn^4
Megabytes=Bytes/1024^2

so we see it goes up as the fourth power of the number of resistors on one side plus 1, or as the forth power of the number of nodes on one edge, and either times the constant 8.

Using that formula, for 100 nodes on one edge we get:
8*100^4=793 megabytes

This starts to become a problem when we work in Windows on the 32 bit platform, because most processes only allow 1 gigabyte of memory per process, which is roughly 1000 megabytes. This would mean that with 100 nodes we are nearing the limit for one process to handle in direct form.
It might be that the 64 bit version will handle more per process, but if it is a 32 bit program anyway i dont know. I'll have to check into this.

I was able to get up to 91 nodes on one edge, but when i tried to do 101 nodes on each edge the mem usage crashed the program. There was no error report which usually means it ran out of memory.
The number of nodes was 10201, so the matrix was a 10201x10201 matrix which means 794 megabytes.
By contrast, the Laplace solution uses a matrix just 16*101x101 which is just 16*Nn^2 which is just about 160 kilobytes.

The number of calculations is quite high for either solution however. I'll have to look into this too at some point just to see what it comes out to. The matrix calculations for Gaussian Elimination are quite simple, like:
Ajk=a-b*c/d

but they have to be repeated a lot of times.

[Idea #3]
The matrix is always sparse, and it could be this reason that 64 bit floating point comes out with a reasonable result all the way up to a 91x91 matrix, which was the highest i was able to test so far because of the memory limitations. I have to update my algorithm to get higher than that, but dont know when i will do that if ever because it is rare that i need to do a 10000x10000 dimension matrix.
In 64 bit floating point, the valid digits are about 12, compared to 16 digits or more when using all integer math. The integer math is exact, so the floating point result is a little less accurate but still within reason.

[Idea #4]
There are various symmetries which we could take advantage of in order to reduce the actual number of nodes that need to be solved for, if the resistors are all the same value which we are usually assuming for this problem.
For a general statement, if we find a node 'n' that has voltage 'v', we can always find at least one more node 'm' that has that same voltage 'v'. This means if we connect these two nodes, we end up reducing the number of nodes by 1.
It just so happens however that if we separate the grid into two triangles, one upper and one lower, we find that the voltages in one triangle are the same as in the other triangle. This reduces the number of nodes by a factor of about 1/2.
We also have a voltage that is always 1/2 of Vcc along the minor diagonal, which means every voltage there is always the same and always that value. That reduces the matrix by the number of nodes along one edge.
I havent done this yet, but reducing the number of nodes by 1/2 of the total means speeding up any solution algorithm by about 2 times.

Last edited: May 19, 2017
11. ### ddurgin New Member

Mar 2, 2011
6
1
Without too much calculating...
1. Total current splits symmetrically flowing down the diamond.
2. So the first (top) tier is equivalent to 2 x 10Ω in parallel; 2nd tier is 4 x 10Ω in parallel and so on.
3. Therefore, R total = 10/2 +10/4 +10/6 +10/8 +10/8 +10/6 +10/4 +10/2 ≈ 20.8333Ω
4. So, Vb = 10V x 5/20.8333 = 2.4V ... and Va = 10V x (20.8333 - 5) / 20.8333 = 7.6V

... I think.

DD

12. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,364
350
You're making the mistake WBahn discusses in post #6.

It was also discussed in post #8 of this thread: https://forum.allaboutcircuits.com/threads/resistance-across-a-mesh-of-wire.13391/

13. ### MrAl Thread Starter Distinguished Member

Jun 17, 2014
3,467
718
Hi,

Thanks for joining the thread. If you are interested in this maybe you can try finding new ways to calculate this too.

Here's the thing though...
The grid viewed as a diamond is not symmetrical in both the x and y directions. There are only certain places horizontally that have an equipotential line that is straight.
If you look back at post #10 in this thread i had proved that although the first two 10 ohm resistors can be viewed as being in parallel and thus the voltages at the bottom of those two are equal, the next row can not be viewed the same way because of that fact that toward the middle of the network there are horizontal interconnecting 10 ohm resistors but at the edge there are no interconnections that go from say the right side to the left side. Thus there is something missing that could force each row of nodes to have the same voltages (viewed as a diamond sitting up on one point again).

The way to prove this is to view it as a diamond sitting up on one point (as i can see you did already) and just assume that any two rows (that have another single third row between them and are both located in the top half or bottom half) have nodes with exactly the same voltage, then calculate the voltages at the third row nodes. You will find that the row in between (the third row) does not have voltages that are all the same, and that proves that at least one row of nodes does not possess equipotential voltages and so there is no simple symmetry. So for example if you choose rows 1 and 3 and assume all voltages are equal, then you can easily calculate the voltages for row 2 and this will show that the voltages are not equal in row 2 so we found one row that is not equipotential.

However, please dont let this stop you from trying to find another way to do this. So far we've done a straight forward nodal as well as a numerical solution that comes from solving Laplaces Equation in two dimensions (or in three dimensions for the resistor cube). I know there is another solution that is more analytic that comes from Laplaces Equation too but i cant remember the method after so many years now. I meant to ask around but did not get around to doing that yet

So keep looking and see what you can find.

Last edited: Jul 25, 2017