Re: Simple Question
- From: Jonathan Kirwan <jkirwan@xxxxxxxxxxxxxx>
- Date: Wed, 27 Sep 2006 23:12:55 GMT
On Wed, 27 Sep 2006 21:49:32 GMT, Rich Grise <rich@xxxxxxxxxxx> wrote:
On Fri, 22 Sep 2006 00:23:28 +0000, Jonathan Kirwan wrote:
On 21 Sep 2006 18:06:05 GMT, Chris Foster <edolan@xxxxxx> wrote:
I have a simple question. This is a qustion that I was asked in a job
interview.
If there existed and infinite two dimewnsional array of 1 ohm resisters,
what is the resistance between two point seperated by a knights move (i.e.
up two, over one, or over two and up one.......etc...)
If I'm not slipping up, the resulting equation would be:
PI PI
/ /
1 | | 1 - cos( 2u + v )
R = ------ * | | ----------------------- du dv
4*PI^2 | | 2 - cos( u ) - cos( v )
/ /
-PI -PI
But thinking as a programmer, I'd probably just solve it numerically,
not through numerical or closed integration of the above, but instead
by:
(a) create a matrix V[] to represent the node voltages
(b) select some central point for A, call it V[x,y]
(c) arbitrarily initialize the matrix node values
to 0.5
(d) initialize matrix element V[x,y] to 0.0.
(e) initialize matrix element V[x+2,y+1] to 1.0.
(f) divide the grid into a checkerboard arrangement
with white and black (or red and black) squares
(g) process all the black squares, those not V[x,y]
or V[x+2,y+1], so that their new value is the
mean of the surrounding four nodes.
(h) process all the white squares, those not V[x,y]
or V[x+2,y+1], so that their new value is the
mean of the surrounding four nodes.
(i) until satisfied, go back to (g).
(j) add up the four node voltages adjacent to V[x,y]
into 'sum'
(k) print 1/(sum-4*V[x,y]) as the resistance.
Which looking at the near center of a 80x80 grid (probably close
enough) comes out to 0.7728 ohms.
As long as you're writing the program, how about a sort of chart, or
graph, of the node-to-node resistance for a whole family of matrix
sizes - 4 x 4, 9 x 9, 10 x 10, 100 x 100, and so on, and see if it
approaches a limit - it might be interesting to see the difference
between, say, 80 x 80 vs. say, 1000 x 1000.
Trivial to do, actually. It's just that the run time right now using
interpreted basic is painful. I may get around to it. But I've
posted my code, too, so anyone else can try a hack at it if they want
to.
Jon
.
- References:
- Simple Question
- From: Chris Foster
- Re: Simple Question
- From: Jonathan Kirwan
- Re: Simple Question
- From: Rich Grise
- Simple Question
- Prev by Date: Re: Simple amplifier: simulation & real world do not agree
- Next by Date: Re: Simple Question
- Previous by thread: Re: Simple Question
- Next by thread: Re: Simple Question
- Index(es):
Relevant Pages
|