Computational Techniques in Theoretical Physics
 

Solutions for Tutorial 1:
 
 

     
Solution:

Physical memory of matrix A:
 

     
    A(1,1) A(1,2) A(1,3) A(1,4) A(1,5) A(1,6) A(1,7) A(1,8) A(1,9) A(1,10)
    A(2,1) A(2,2) A(2,3) A(2,4) A(2,5) A(2,6) A(2,7) A(2,8) A(2,9) A(2,10)
    A(3,1) A(3,2) A(3,3) A(3,4) A(3,5) A(3,6) A(3,7) A(3,8) A(3,9) A(3,10)
    A(4,1) A(4,2) A(4,3) A(4,4) A(4,5) A(4,6) A(4,7) A(4,8) A(4,9) A(4,10)
    A(5,1) A(5,2) A(5,3) A(5,4) A(5,5) A(5,6) A(5,7) A(5,8) A(5,9) A(5,10)
    A(6,1) A(6,2) A(6,3) A(6,4) A(6,5) A(6,6) A(6,7) A(6,8) A(6,9) A(6,10)
    A(7,1) A(7,2) A(7,3) A(7,4) A(7,5) A(7,6) A(7,7) A(7,8) A(7,9) A(7,10)
    A(8,1) A(8,2) A(8,3) A(8,4) A(8,5) A(8,6) A(8,7) A(8,8) A(8,9) A(8,10)
    A(9,1) A(9,2) A(9,3) A(9,4) A(9,5) A(9,6) A(9,7) A(9,8) A(9,9) A(9,10)
    A(10,1) A(10,2) A(10,3) A(10,4) A(10,5) A(10,6) A(10,7) A(10,8) A(10,9) A(10,10)
     
Physical memory of local matrix:
 
     
    A(1,1) A(1,2) A(1,3) A(1,4) A(1,5) A(1,6) ____ ____ ____ ____
    A(2,1) A(2,2) A(2,3) A(2,4) A(2,5) A(2,6) _ _ _ _
    A(3,1) A(3,2) A(3,3) A(3,4) A(3,5) A(3,6) _ _ _ _
    A(4,1) A(4,2) A(4,3) A(4,4) A(4,5) A(4,6) _ _ _ _
    A(5,1) A(5,2) A(5,3) A(5,4) A(5,5) A(5,6) _ _ _ _
    __ _ _ _ _ _ _ _ _ _
    _ _ _ _ _ _ _ _ _ _
    _ _ _ _ _ _ _ _ _ _
    _ _ _ _ _ _ _ _ _ _
    _ _ _ _ _ _ _ _ _ _
     
 
 
     
 
Solution:
 
Linear congruential method:

Xn+1 = (a Xn + c) mod m

For m=10 and X0=a=c=7
 

X0 = 7
X1 = (7 * 7 + 7) mod 10 = 6
X2 = (7 * 6 + 7) mod 10 = 9
X3 = (7 * 9 + 7) mod 10 = 0
X4 = (7 * 0 + 7) mod 10 = 7
X5 = (7 * 7 + 7) mod 10 = 6
X6 = (7 * 6 + 7) mod 10 = 9
X7 = (7 * 9 + 7) mod 10 = 0
For m=30 and X0=a=c=14
 
X0=14
X1=(14 * 14 + 14) mod 30 = 0
X2=(14 *  0  + 14) mod 30 = 14
X3=(14 * 14 + 14) mod 30 = 0