AlphaGreen

10 Reputation

One Badge

8 years, 239 days

MaplePrimes Activity


These are replies submitted by AlphaGreen

@tomleslie 

 

Thanks for the other file. Yeah, I was aproaching this second bit wrong so sorry for wasting your time!

I've got to sort of where I need to be but coding it is actually the problem now! I've started to do it;

So for example we have dimensions
Row := 3
Col := 3
 
Setting i:= 1. j:=1, RBndE:=0, CBndE:=0
 
Want the TBndE = RBndE + CBndE where;
RBndE = RBndE +  P(i, j)*P(i, j+1)
CBndE = CBndE  + P(i, j)*P(i+1, j)

As instead of adding them, if I multiply then by eachother I get 1 when they are the same and -1 when they aren't which is what I want. 
 
Need to set it out so that it goes along each row/column
So for the 3x3 example, it would do point (1,1)*(1,2) add it to (this example) RBndE. Then (1, 2)*(1, 3) add it then go to (2, 1)*(2, 2) etc until it had done P(Row, Col) then the same for the vertical connections.
 
I want a loop/proc that does this, I started by trying to set it out so after each calculation it added 1 to i(or j)  after each calc but this became tedious. I also need it to make sure it doesn’t “move” to forbidden areas, say here would be (1, 3)*(1,4). Obviously the final output would be TBndE of the matrix.

Any suggestions on where to go with this would be unbelievably appreciated!

Cheers
Jordan 

@tomleslie 

Big thanks for the first part.

Its not quite the nearest neighbour, that was a poor explanation from me. It is only the the direct up/down or across "bond" so if the matrix was [(A, B), (C, D)] then I would need AB,AC, CD, BD connections.

It can be written as  each point multipled by the next and then summed, as this would give me the desired 1/-1. But I'm unsure how to write it so it dosent "Wrap around" (i.e. Calculating BC from the example above) so I need it to in simple steps;

starting at the first entry go along each row systematically multiplying its current point by the next one (1+n) across from it, add it to value "E"

move on to (1+n) horizontally, reapeat so (1+n * 1+2n) until at the end of the row,

go to the next the row and keep going until the last entry (i?)

and then repeat the same for the columns, still adding the value of E.

Has this made it any clearer? Its hard to write the maths out of it as its simply done by inspection for smaller cases.

Page 1 of 1