Sponsored links: Algebra eBooks
 

Related

xreduce

Run Example
(%i1)modulus:2;
(%o1)                                  2
(%i2)  N:2;
(%o2)                                  2
(%i3)   block( P:0, Vars:[], Sol:zeromatrix(N,N), for i: 1 thru N do ( for j: 1 thru N do ( S:zeromatrix(N+2,N+2), S[i ][j ]:1, S[i ][j+1]:1,  S[i ][j+2]:1, S[i+1][j ]:1, S[i+1][j+2]:1, S[i+2][j ]:1, S[i+2][j+1]:1, S[i+2][j+2]:1, S:submatrix (1,N+2,S,1,N+2), P:P+V[i*N+j]*S, Vars: append(Vars, [V[i*N+j]]), Sol[i][j]:V[i*N+j]) ) );
(%o3)                                done
(%i4)  P;
                        [ V  + V  + V   V  + V  + V  ]
                        [  6    5    4   6    5    3 ]
(%o4)                   [                            ]
                        [ V  + V  + V   V  + V  + V  ]
                        [  6    4    3   5    4    3 ]
(%i5)  Vars;
(%o5)                          [V , V , V , V ]
                                 3   4   5   6
(%i6)  R:zeromatrix(N,N)+1;
                                   [ 1  1 ]
(%o6)                              [      ]
                                   [ 1  1 ]
(%i7)  LGS:xreduce('append ,args(P-R));
(%o7) [V  + V  + V  - 1, V  + V  + V  - 1, V  + V  + V  - 1, V  + V  + V  - 1]
        6    5    4       6    5    3       6    4    3       5    4    3
(%i8)  Res:algsys(LGS, Vars);
(%o8)                 [[V  = 1, V  = 1, V  = 1, V  = 1]]
                         3       4       5       6
(%i9)  append([l=Sol],Res[1]);
                    [ V   V  ]
                    [  3   4 ]
(%o9)          [l = [        ], V  = 1, V  = 1, V  = 1, V  = 1]
                    [ V   V  ]   3       4       5       6
                    [  5   6 ]
(%i10) 
Run Example
modulus:2;
(%o1)                                  2
(%i2)  N:4;
(%o2)                                  4
(%i3)   block( P:0, Vars:[], Sol:zeromatrix(N,N), for i: 1 thru N do ( for j: 1 thru N do ( S:zeromatrix(N+2,N+2), S[i ][j ]:1, S[i ][j+1]:1,  S[i ][j+2]:1, S[i+1][j ]:1, S[i+1][j+2]:1, S[i+2][j ]:1, S[i+2][j+1]:1, S[i+2][j+2]:1, S:submatrix (1,N+2,S,1,N+2), P:P+V[i*N+j]*S, Vars: append(Vars, [V[i*N+j]]), Sol[i][j]:V[i*N+j]) ) ,  R:zeromatrix(N,N)+1, LGS:xreduce('append ,args(P-R)), globalsolve:%true, solve(LGS, Vars),   Sol:zeromatrix(N,N), for i: 1 thru N do ( for j: 1 thru N do (Sol[i][j]:V[i*N+j]) ) );

solve: dependent equations eliminated: (16 13 10 14)
(%o3)                                done
(%i4)   Sol;
               [ %r4 + %r3 - %r2 + %r1 + 1 ]         [   - %r4 - %r1   ]
               [                           ]         [                 ]
               [      - %r2 + %r1 + 1      ]         [    %r4 + %r2    ]
(%o4)  Col 1 = [                           ] Col 2 = [                 ]
               [            %r4            ]         [       %r3       ]
               [                           ]         [                 ]
               [          %r1 - 1          ]         [ - %r4 - %r3 + 1 ]
                      [ - %r3 - %r2 + %r1 + 1 ]         [       1 - %r3       ]
                      [                       ]         [                     ]
                      [          %r1          ]         [      %r3 + %r2      ]
              Col 3 = [                       ] Col 4 = [                     ]
                      [ %r4 + %r3 + %r2 - %r1 ]         [ %r4 + %r3 - %r1 - 1 ]
                      [                       ]         [                     ]
                      [          %r2          ]         [   - %r4 - %r2 + 1   ]
(%i5) 
Run Example
game[N]:=  block(modulus:2, P:0, Vars:[], Sol:zeromatrix(N,N), for i: 1 thru N do ( for j: 1 thru N do ( S:zeromatrix(N+2,N+2), S[i ][j ]:1, S[i ][j+1]:1,  S[i ][j+2]:1, S[i+1][j ]:1, S[i+1][j+2]:1, S[i+2][j ]:1, S[i+2][j+1]:1, S[i+2][j+2]:1, S:submatrix (1,N+2,S,1,N+2), P:P+V[i*N+j]*S, Vars: append(Vars, [V[i*N+j]]), Sol[i][j]:V[i*N+j]) ) ,  R:zeromatrix(N,N)+1, LGS:xreduce('append ,args(P-R)), globalsolve:%true, solve(LGS, Vars),   Sol:zeromatrix(N,N), for i: 1 thru N do ( for j: 1 thru N do (Sol[i][j]:V[i*N+j]) ) );
(%o1) game  := block(modulus : 2, P : 0, Vars : [], Sol : zeromatrix(N, N), 
          N
for i thru N do (for j thru N do (S : zeromatrix(N + 2, N + 2), (S )  : 1, 
                                                                  i
                                                                    j
(S )      : 1, (S )      : 1, (S     )  : 1, (S     )      : 1, (S     )  : 1, 
  i              i              i + 1          i + 1              i + 2
    j + 1          j + 2              j              j + 2              j
(S     )      : 1, (S     )      : 1, S : submatrix(1, N + 2, S, 1, N + 2), 
  i + 2              i + 2
        j + 1              j + 2
P : P + V        S, Vars : append(Vars, [V       ]), (Sol )  : V       )), 
         i N + j                          i N + j        i      i N + j
                                                           j
R : zeromatrix(N, N) + 1, LGS : xreduce('append, args(P - R)), 
globalsolve : %true, solve(LGS, Vars), Sol : zeromatrix(N, N), 
for i thru N do (for j thru N do (Sol )  : V       ))
                                     i      i N + j
                                       j
(%i2)   Sol;
(%o2)                                 Sol
(%i3) game[2];
(%o3)                                done
(%i4) 

Related Help

Help for Xreduce