arara:# gp GP/PARI CALCULATOR Version 2.12.1 (development 25142-46eb34041) i386 running darwin (x86-64/GMP-6.2.0 kernel) 64-bit version compiled: Mar 22 2020, Apple clang version 11.0.0 (clang-1100.0.33.17) threading engine: single (readline v8.0 enabled, extended help enabled) Copyright (C) 2000-2020 The PARI Group PARI/GP is free software, covered by the GNU General Public License, and comes WITHOUT ANY WARRANTY WHATSOEVER. Type ? for help, \q to quit. Type ?17 for how to get moral (and possibly technical) support. parisize = 8000000, primelimit = 500000 ? ?Mod Mod(a,b): create 'a modulo b'. ? ?lift lift(x,{v}): if v is omitted, lifts elements of Z/nZ to Z, of Qp to Q, and of K[x]/(P) to K[x]. Otherwise lift only polmods with main variable v. ? ?liftint liftint(x): lifts every element of Z/nZ to Z and of Qp to Q. ? Mod(2*2,3) %1 = Mod(1, 3) ? liftint(Mod(2*2,3)) %2 = 1 ? p=3 %3 = 3 ? matrix(p,p,a,b,a+b) %4 = [2 3 4] [3 4 5] [4 5 6] ? matrix(p,p,a,b,Mod(a+b,p)) %5 = [Mod(2, 3) Mod(0, 3) Mod(1, 3)] [Mod(0, 3) Mod(1, 3) Mod(2, 3)] [Mod(1, 3) Mod(2, 3) Mod(0, 3)] ? matrix(p,p,a,b,liftint(Mod(a+b,p))) %6 = [2 0 1] [0 1 2] [1 2 0] ? matrix(p,p,a,b,s(a+b)) *** at top-level: matrix(p,p,a,b,s(a+b)) *** ^------- *** not a function in function call *** Break loop: type 'break' to go back to GP prompt break> break ? s(x) = liftint(Mod(x,p)) %7 = (x)->liftint(Mod(x,p)) ? matrix(p,p,a,b,s(a+b)) %8 = [2 0 1] [0 1 2] [1 2 0] ? p=4;matrix(p,p,a,b,s(a+b)) %9 = [2 3 0 1] [3 0 1 2] [0 1 2 3] [1 2 3 0] ? p=5;matrix(p,p,a,b,s(a+b)) %10 = [2 3 4 0 1] [3 4 0 1 2] [4 0 1 2 3] [0 1 2 3 4] [1 2 3 4 0] ? p=6;matrix(p,p,a,b,s(a+b)) %11 = [2 3 4 5 0 1] [3 4 5 0 1 2] [4 5 0 1 2 3] [5 0 1 2 3 4] [0 1 2 3 4 5] [1 2 3 4 5 0] ? p=7;matrix(p,p,a,b,s(a+b)) %12 = [2 3 4 5 6 0 1] [3 4 5 6 0 1 2] [4 5 6 0 1 2 3] [5 6 0 1 2 3 4] [6 0 1 2 3 4 5] [0 1 2 3 4 5 6] [1 2 3 4 5 6 0] ? p=8;matrix(p,p,a,b,s(a+b)) %13 = [2 3 4 5 6 7 0 1] [3 4 5 6 7 0 1 2] [4 5 6 7 0 1 2 3] [5 6 7 0 1 2 3 4] [6 7 0 1 2 3 4 5] [7 0 1 2 3 4 5 6] [0 1 2 3 4 5 6 7] [1 2 3 4 5 6 7 0] ? p=2;matrix(p,p,a,b,s(a*b)) %14 = [1 0] [0 0] ? p=3;matrix(p,p,a,b,s(a*b)) %15 = [1 2 0] [2 1 0] [0 0 0] ? M(p) = matrix(p,p,a,b,s(a*b)) %16 = (p)->matrix(p,p,a,b,s(a*b)) ? M(2) %17 = [1 2] [2 1] ? ?s s = (x)->liftint(Mod(x,p)) ? kill(p) ? M(p) = matrix(p,p,a,b,s(a*b)) %19 = (p)->matrix(p,p,a,b,s(a*b)) ? M(2) %20 = [Mod(1, p) Mod(2, p)] [Mod(2, p) Mod(4, p)] ? ?s s = (x)->liftint(Mod(x,p)) ? s(x,p) = liftint(Mod(x,p)) %21 = (x,p)->liftint(Mod(x,p)) ? M(p) = matrix(p,p,a,b,s(a*b,p)) %22 = (p)->matrix(p,p,a,b,s(a*b,p)) ? M(2) %23 = [1 0] [0 0] ? ?M M = (p)->matrix(p,p,a,b,s(a*b,p)) ? ?s s = (x,p)->liftint(Mod(x,p)) ? "s para representante Mod p enter 0 e p-1" %24 = "s para representante Mod p enter 0 e p-1" ? "M(p) e uma tabua de multiplicação mod p para um inteiro p" %25 = "M(p) e uma tabua de multiplicação mod p para um inteiro p" ? Mod(4,-5) %26 = Mod(4, 5) ? Mod(-4,-5) %27 = Mod(1, 5) ? s(-2) *** at top-level: s(-2) *** ^----- *** in function s: liftint(Mod(x,p)) *** ^--------- *** Mod: impossible inverse in %: 0. *** Break loop: type 'break' to go back to GP prompt break> break ? s(2) *** at top-level: s(2) *** ^---- *** in function s: liftint(Mod(x,p)) *** ^--------- *** Mod: impossible inverse in %: 0. *** Break loop: type 'break' to go back to GP prompt break> break ? M(-2) *** at top-level: M(-2) *** ^----- *** in function M: matrix(p,p,a,b,s(a*b,p)) *** ^------------------------ *** matrix: domain error in matrix: nbcols < 0 *** Break loop: type 'break' to go back to GP prompt break> break ? M(2) %28 = [1 0] [0 0] ? ?M M = (p)->matrix(p,p,a,b,s(a*b,p)) ? Mod(4,5) == Mod(4,-5) %29 = 1 ? M(p) = matrix(abs(p),abs(p),a,b,s(a*b,p)) %30 = (p)->matrix(abs(p),abs(p),a,b,s(a*b,p)) ? ?abs abs(x): absolute value (or modulus) of x. ? abs(-5) %31 = 5 ? M(-2) %32 = [1 0] [0 0] ? M(-2) == M(2) %33 = 1 ? M(3) %34 = [1 2 0] [2 1 0] [0 0 0] ? ?M M = (p)->matrix(abs(p),abs(p),a,b,s(a*b,p)) ? ?matrix matrix(m,{n=m},{X},{Y},{expr=0}): m x n matrix of expression expr, where the row variable X goes from 1 to m and the column variable Y goes from 1 to n. By default, fill with 0s. ? "variavel de reta vai 1 ate p, então 0 aqui é no fim de tabua" %35 = "variavel de reta vai 1 ate p, então 0 aqui é no fim de tabua" ? ?mat matadjoint mathess matintersect matqr matalgtobasis mathilbert matinverseimage matrank matbasistoalg mathnf matinvmod matreduce matcompanion mathnfmod matisdiagonal matrix matconcat mathnfmodid matker matrixqz matdet mathouseholder matkerint matsize matdetint matid matkermod matsnf matdetmod matimage matmuldiagonal matsolve matdiagonal matimagecompl matmultodiagonal matsolvemod mateigen matimagemod matpascal matsupplement matfrobenius matindexrank matpermanent mattranspose ? ?M M = (p)->matrix(abs(p),abs(p),a,b,s(a*b,p)) ? N(p) = matrix(abs(p)-1,abs(p)-1,a,b,s(a*b,p)) %36 = (p)->matrix(abs(p)-1,abs(p)-1,a,b,s(a*b,p)) ? N(3) %37 = [1 2] [2 1] ? M(3) %38 = [1 2 0] [2 1 0] [0 0 0] ? MM(p) = matrix(abs(p),abs(p),a,b,s((a-1)*(b-1),p)) %39 = (p)->matrix(abs(p),abs(p),a,b,s((a-1)*(b-1),p)) ? M(3) %40 = [1 2 0] [2 1 0] [0 0 0] ? MM(3) %41 = [0 0 0] [0 1 2] [0 2 1] ? N(2) %42 = [1] ? N(3) %43 = [1 2] [2 1] ? N(4) %44 = [1 2 3] [2 0 2] [3 2 1] ? M(4) %45 = [1 2 3 0] [2 0 2 0] [3 2 1 0] [0 0 0 0] ? MM(4) %46 = [0 0 0 0] [0 1 2 3] [0 2 0 2] [0 3 2 1] ? ?mat matadjoint mathess matintersect matqr matalgtobasis mathilbert matinverseimage matrank matbasistoalg mathnf matinvmod matreduce matcompanion mathnfmod matisdiagonal matrix matconcat mathnfmodid matker matrixqz matdet mathouseholder matkerint matsize matdetint matid matkermod matsnf matdetmod matimage matmuldiagonal matsolve matdiagonal matimagecompl matmultodiagonal matsolvemod mateigen matimagemod matpascal matsupplement matfrobenius matindexrank matpermanent mattranspose ? ?vec vecextract vecmin vecsearch vecsum vectorsmall vecmax vecprod vecsort vector vectorv ? ?vecextract vecextract(x,y,{z}): extraction of the components of the matrix or vector x according to y and z. If z is omitted, y represents columns, otherwise y corresponds to rows and z to columns. y and z can be vectors (of indices), strings (indicating ranges as in "1..10") or masks (integers whose binary representation indicates the indices to extract, from left to right 1, 2, 4, 8, etc.). ? MM(4) %47 = [0 0 0 0] [0 1 2 3] [0 2 0 2] [0 3 2 1] ? % %48 = [0 0 0 0] [0 1 2 3] [0 2 0 2] [0 3 2 1] ? %48 == %47 %49 = 1 ? %47 %50 = [0 0 0 0] [0 1 2 3] [0 2 0 2] [0 3 2 1] ? vecextract(%,[2,4],[2,4]) %51 = [1 3] [3 1] ? M(4) %52 = [1 2 3 0] [2 0 2 0] [3 2 1 0] [0 0 0 0] ? vecextract(M(4),[1,3],[1,3]) %53 = [1 3] [3 1] ? "Modulo 4 residuous intersiveis são 1 e 3, e eles formam um grupo de 2 elemen tos, o mesmo grupo que a gente já viu como residuous modulo 2 com + e tb residu os modulo inversiveis com *" %54 = "Modulo 4 residuous intersiveis são 1 e 3, e eles formam um grupo de 2 elementos, o mesmo grupo que a gente já viu como residuous modulo 2 com + e tb residuos modulo inversiveis com *" ? M(5) %55 = [1 2 3 4 0] [2 4 1 3 0] [3 1 4 2 0] [4 3 2 1 0] [0 0 0 0 0] ? vecextract(M(5),"1..4",[1,2,3,4]) %56 = [1 2 3 4] [2 4 1 3] [3 1 4 2] [4 3 2 1] ? ?vecextract vecextract(x,y,{z}): extraction of the components of the matrix or vector x according to y and z. If z is omitted, y represents columns, otherwise y corresponds to rows and z to columns. y and z can be vectors (of indices), strings (indicating ranges as in "1..10") or masks (integers whose binary representation indicates the indices to extract, from left to right 1, 2, 4, 8, etc.). ? A(n) = matrix(n,n,a,b,liftint(Mod((a-1)+(b-1),n))) %57 = (n)->matrix(n,n,a,b,liftint(Mod((a-1)+(b-1),n))) ? A(4) %58 = [0 1 2 3] [1 2 3 0] [2 3 0 1] [3 0 1 2] ? N(5) %59 = [1 2 3 4] [2 4 1 3] [3 1 4 2] [4 3 2 1] ? "Aqui uma pergunta - estes 2 tabuas podem ser iguas depois renomeamento?" %60 = "Aqui uma pergunta - estes 2 tabuas podem ser iguas depois renomeamento?" ? Letras = [a,b,c,d] %61 = [a, b, c, d] ? N(5) %62 = [1 2 3 4] [2 4 1 3] [3 1 4 2] [4 3 2 1] ? matrix(4,4,u,v,N(5)[u,v]) %63 = [1 2 3 4] [2 4 1 3] [3 1 4 2] [4 3 2 1] ? matrix(4,4,u,v,Letras[N(5)[u,v]]) %64 = [a b c d] [b d a c] [c a d b] [d c b a] ? N(5) %65 = [1 2 3 4] [2 4 1 3] [3 1 4 2] [4 3 2 1] ? M(8) %66 = [1 2 3 4 5 6 7 0] [2 4 6 0 2 4 6 0] [3 6 1 4 7 2 5 0] [4 0 4 0 4 0 4 0] [5 2 7 4 1 6 3 0] [6 4 2 0 6 4 2 0] [7 6 5 4 3 2 1 0] [0 0 0 0 0 0 0 0] ? vecextract(M(8),[1,3,5,7],[1,3,5,7]) %67 = [1 3 5 7] [3 1 7 5] [5 7 1 3] [7 5 3 1] ? "Quais destes grupos de 4 elementos são isomorfos um doutro: Z/4, (Z/5)^*, (Z /8)^* ?" %68 = "Quais destes grupos de 4 elementos são isomorfos um doutro: Z/4, (Z/5)^*, (Z/8)^* ?" ? matrix(4,4,u,v,Letras[N(5)[u,v]]) %69 = [a b c d] [b d a c] [c a d b] [d c b a] ? M5literal = matrix(4,4,u,v,Letras[N(5)[u,v]]) %70 = [a b c d] [b d a c] [c a d b] [d c b a] ? subtvec(M5literal, [a,b,c,d], [Sergey, Rafael, Felipe, Tomás]) *** syntax error, unexpected $undefined, expecting ',': *** ...rgey,Rafael,Felipe,Tomás]) *** ^-- ? subtvec(M5literal, [a,b,c,d], [Sergey, Rafael, Felipe, Tomas]) *** at top-level: subtvec(M5literal,[a,b,c,d],[Sergey,Rafael,Fel *** ^---------------------------------------------- *** not a function in function call *** Break loop: type 'break' to go back to GP prompt break> break ? substvec(M5literal, [a,b,c,d], [Sergey, Rafael, Felipe, Tomás]) *** syntax error, unexpected $undefined, expecting ',': *** ...rgey,Rafael,Felipe,Tomás]) *** ^-- ? substvec(M5literal, [a,b,c,d], [Sergey, Rafael, Felipe, Tomas]) %71 = [Sergey Rafael Felipe Tomas] [Rafael Tomas Sergey Felipe] [Felipe Sergey Tomas Rafael] [ Tomas Felipe Rafael Sergey] ? subst(%,Tomas,Giovanna) %72 = [ Sergey Rafael Felipe Giovanna] [ Rafael Giovanna Sergey Felipe] [ Felipe Sergey Giovanna Rafael] [Giovanna Felipe Rafael Sergey] ? subst(%,Rafael,Raphael) %73 = [ Sergey Raphael Felipe Giovanna] [ Raphael Giovanna Sergey Felipe] [ Felipe Sergey Giovanna Raphael] [Giovanna Felipe Raphael Sergey] ? subst(%,Sergey, Rafael) %74 = [ Rafael Raphael Felipe Giovanna] [ Raphael Giovanna Rafael Felipe] [ Felipe Rafael Giovanna Raphael] [Giovanna Felipe Raphael Rafael] ? "A gente pode usar subst e substvec para renomear elementos, mas para mudar o rdem deles a gente precisa outra operação" %75 = "A gente pode usar subst e substvec para renomear elementos, mas para mudar ordem deles a gente precisa outra operação" ? S12 = [0,1,0,0;1,0,0,0;0,0,1,0;0,0,0,1] %76 = [0 1 0 0] [1 0 0 0] [0 0 1 0] [0 0 0 1] ? S12 * %74 * S12 %77 = [Giovanna Raphael Rafael Felipe] [ Raphael Rafael Felipe Giovanna] [ Rafael Felipe Giovanna Raphael] [ Felipe Giovanna Raphael Rafael] ? %74 %78 = [ Rafael Raphael Felipe Giovanna] [ Raphael Giovanna Rafael Felipe] [ Felipe Rafael Giovanna Raphael] [Giovanna Felipe Raphael Rafael] ? vector(8,n,Mod(n^2,8)) %79 = [Mod(1, 8), Mod(4, 8), Mod(1, 8), Mod(0, 8), Mod(1, 8), Mod(4, 8), Mod(1, 8), Mod(0, 8)] ? liftint(%) %80 = [1, 4, 1, 0, 1, 4, 1, 0] ? "NB: Para cado número impar seu quadrado igual 1 modulo 8" %81 = "NB: Para cado número impar seu quadrado igual 1 modulo 8" ? Mod(2+2,4) %82 = Mod(0, 4) ? Mod(1+1,4) %83 = Mod(2, 4) ? a = Mod(1,4) %84 = Mod(1, 4) ? a+a %85 = Mod(2, 4) ? a+a+a %86 = Mod(3, 4) ? a+a+a+a %87 = Mod(0, 4) ? Goodbye!