Logging to /Users/s/tmp/pari-02.04 GPRC Done. 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 = 40000000, primelimit = 1000000 (15:23) gp > ?\l # : enable/disable timer ## : print time for last result \\ : comment up to end of line \a {n} : print result in raw format (readable by PARI) \B {n} : print result in beautified format \c : list all commands (same effect as ?*) \d : print all defaults \e {n} : enable/disable echo (set echo=n) \g {n} : set debugging level \gf{n} : set file debugging level \gm{n} : set memory debugging level \h {m-n}: hashtable information \l {f} : enable/disable logfile (set logfile=f) \m {n} : print result in prettymatrix format \o {n} : set output method (0=raw, 1=prettymatrix, 2=prettyprint, 3=2-dim) \p {n} : change real precision \pb{n} : change real bit precision \ps{n} : change series precision \q : quit completely this GP session \r {f} : read in a file \s : print stack information \t : print the list of PARI types \u : print the list of user-defined functions \um : print the list of user-defined member functions \v : print current version of GP \w {nf} : write to a file \x {n} : print complete inner structure of result \y {n} : disable/enable automatic simplification (set simplify=n) {f}=optional filename. {n}=optional integer (15:26) gp > ?floor floor(x): floor of x = largest integer <= x. (15:27) gp > ?ceil ceil(x): ceiling of x = smallest integer >= x. (15:27) gp > ?round round(x,{&e}): take the nearest integer to all the coefficients of x. If e is present, do not take into account loss of integer part precision, and set e = error estimate in bits. (15:27) gp > ?frac frac(x): fractional part of x = x-floor(x). (15:27) gp > frac(420/57) %1 = 7/19 (15:30) gp > "Esse significa que 7 é um residuo de 420 modulo 57" %2 = "Esse significa que 7 é um residuo de 420 modulo 57" (15:31) gp > Mod(420,57) %3 = Mod(21, 57) (15:31) gp > "Se 420 e 57 seria coprimos, %1 significaria que 7 é um residuo de 420 modulo 57. Mas vamos ver o que e divisor maximo comum deles:" %4 = "Se 420 e 57 seria coprimos, %1 significaria que 7 é um residuo de 420 modulo 57. Mas vamos ver o que e divisor maximo comum deles:" (15:32) gp > gcd(420,57) %5 = 3 (15:32) gp > 420/57 %6 = 140/19 (15:32) gp > frac(140/19) %7 = 7/19 (15:32) gp > %7==%1 %8 = 1 (15:32) gp > "NB que denominador de frac(420/57) igual 19 - é diferente de 57, significa que o racio original não é reduzido" %9 = "NB que denominador de frac(420/57) igual 19 - é diferente de 57, significa que o racio original não é reduzido" (15:34) gp > frac(exp(1)) %10 = 0.71828182845904523536028747135266249776 (15:35) gp > frac(Pi) %11 = 0.14159265358979323846264338327950288420 (15:35) gp > Pi %12 = 3.1415926535897932384626433832795028842 (15:35) gp > frac(7*Pi) %13 = 0.99114857512855266923850368295652018938 (15:35) gp > vector(30,n,floor(10*frac(Pi*10^n))) %14 = [4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5] (15:36) gp > vector(30,n,floor(10*frac(Pi*10^(n-1)))) %15 = [1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9] (15:36) gp > vector(30,n,floor(10*frac(Pi*10^(n-2)))) %16 = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7] (15:36) gp > Pi %17 = 3.1415926535897932384626433832795028842 (15:39) gp > digitos(x,N)=vector(N,n,floor(10*frac(x*10^n))) %18 = (x,N)->vector(N,n,floor(10*frac(x*10^n))) (15:40) gp > digitos(Pi,10) %19 = [4, 1, 5, 9, 2, 6, 5, 3, 5, 8] (15:40) gp > digitos(e,10) %20 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] (15:40) gp > digitos(exp(1),10) %21 = [1, 8, 2, 8, 1, 8, 2, 8, 4, 5] (15:40) gp > Pi %22 = 3.1415926535897932384626433832795028842 (15:40) gp > exp(1) %23 = 2.7182818284590452353602874713526624978 (15:40) gp > digitos(log(2),10) %24 = [9, 3, 1, 4, 7, 1, 8, 0, 5, 5] (15:40) gp > digitos(2/7,30) %25 = [8, 5, 7, 1, 4, 2, 8, 5, 7, 1, 4, 2, 8, 5, 7, 1, 4, 2, 8, 5, 7, 1, 4, 2, 8, 5, 7, 1, 4, 2] (15:41) gp > tm(p)=matrix(p-1,p-1,a,b,liftint(Mod(a*b,p))) %26 = (p)->matrix(p-1,p-1,a,b,liftint(Mod(a*b,p))) (15:42) gp > tm(5) %27 = [1 2 3 4] [2 4 1 3] [3 1 4 2] [4 3 2 1] (15:42) gp > tm(7) %28 = [1 2 3 4 5 6] [2 4 6 1 3 5] [3 6 2 5 1 4] [4 1 5 2 6 3] [5 3 1 6 4 2] [6 5 4 3 2 1] (15:42) gp > tm(11) %29 = [ 1 2 3 4 5 6 7 8 9 10] [ 2 4 6 8 10 1 3 5 7 9] [ 3 6 9 1 4 7 10 2 5 8] [ 4 8 1 5 9 2 6 10 3 7] [ 5 10 4 9 3 8 2 7 1 6] [ 6 1 7 2 8 3 9 4 10 5] [ 7 3 10 6 2 9 5 1 8 4] [ 8 5 2 10 7 4 1 9 6 3] [ 9 7 5 3 1 10 8 6 4 2] [10 9 8 7 6 5 4 3 2 1] (15:42) gp > tm(13) %30 = [ 1 2 3 4 5 6 7 8 9 10 11 12] [ 2 4 6 8 10 12 1 3 5 7 9 11] [ 3 6 9 12 2 5 8 11 1 4 7 10] [ 4 8 12 3 7 11 2 6 10 1 5 9] [ 5 10 2 7 12 4 9 1 6 11 3 8] [ 6 12 5 11 4 10 3 9 2 8 1 7] [ 7 1 8 2 9 3 10 4 11 5 12 6] [ 8 3 11 6 1 9 4 12 7 2 10 5] [ 9 5 1 10 6 2 11 7 3 12 8 4] [10 7 4 1 11 8 5 2 12 9 6 3] [11 9 7 5 3 1 12 10 8 6 4 2] [12 11 10 9 8 7 6 5 4 3 2 1] (15:42) gp > "%30 é um tabula de multiplicação modulo 13" %31 = "%30 é um tabula de multiplicação modulo 13" (15:43) gp > f(m)=if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) %32 = (m)->if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) (16:52) gp > ?sum sum(X=a,b,expr,{x=0}): x plus the sum (X goes from a to b) of expression expr. (16:52) gp > ?if if(a,{seq1},{seq2}): if a is nonzero, seq1 is evaluated, otherwise seq2. seq1 and seq2 are optional, and if seq2 is omitted, the preceding comma can be omitted also. (16:52) gp > ?f f = (m)->if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) (16:52) gp > f(0) %33 = 1 (16:52) gp > f(1) %34 = 1 (16:52) gp > f(2) %35 = 2 (16:52) gp > f(3) %36 = 5 (16:52) gp > vector(20,n,f(n)) *** [...] at: ...(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^---------- *** in function f: ...(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^---------- *** in function f: ...(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^---------- *** in function f: if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^--------------- *** in function f: if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^--------------- *** in function f: if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^--------------------------------- *** _==_: user interrupt after 7,377 ms *** Break loop: to continue; 'break' to go back to GP prompt break> break (16:53) gp > vector(5,n,f(n)) %37 = [1, 2, 5, 14, 42] (16:53) gp > vector(10,n,f(n)) time = 15 ms. %38 = [1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796] (16:53) gp > g(n)=binomial(2*n,n)/(n+1) %39 = (n)->binomial(2*n,n)/(n+1) (16:59) gp > vector(10,n,g(n)) %40 = [1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796] (16:59) gp > %38==%40 %41 = 1 (16:59) gp > h(n)=f(n)-g(n) %42 = (n)->f(n)-g(n) (16:59) gp > for(n=1,100,if(h(n)==0,print(n," - verdadeiro!"," - FALSO!!!!!!!!!!")) *** syntax error, unexpected $end, expecting )-> or ',' or ')': ...o!"," - *** FALSO!!!!!!!!!!")) *** ^- (17:00) gp > for(n=1,100,print(n,if(,h(n)," - verdadeiro!"," - FALSO!!!!!!!!!!"))) *** missing mandatory argument: for(n=1,100,print(n,if(,h(n)," - verdadeiro!", *** ^----------------------- (17:01) gp > for(n=1,100,print(n,if(!h(n)," - verdadeiro!"," - FALSO!!!!!!!!!!"))) 1 - verdadeiro! 2 - verdadeiro! 3 - verdadeiro! 4 - verdadeiro! 5 - verdadeiro! 6 - verdadeiro! 7 - verdadeiro! 8 - verdadeiro! 9 - verdadeiro! 10 - verdadeiro! 11 - verdadeiro! 12 - verdadeiro! 13 - verdadeiro! 14 - verdadeiro! 15 - verdadeiro! 16 - verdadeiro! 17 - verdadeiro! *** [...] at: ...(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^---------- *** in function f: if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^--------------- *** in function f: ...(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^---------- *** in function f: if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^--------------- *** in function f: ...(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^---------- *** in function f: if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) *** ^------------------- *** user interrupt after 1min, 4,234 ms *** Break loop: to continue; 'break' to go back to GP prompt break> break (17:02) gp > ?f f = (m)->if(m==0,1,sum(a=0,m-1,f(a)*f(m-1-a))) (17:03) gp > newf(m)=v=vector(m+1);v[1]=1;for(n=1,m+1,v[n]=sum(a=0,n-1,v[a+1]*v[n-a]));return(v[m+1]) %43 = (m)->v=vector(m+1);v[1]=1;for(n=1,m+1,v[n]=sum(a=0,n-1,v[a+1]*v[n-a]));return(v[m+1]) (17:04) gp > newf(15) %44 = 0 (17:04) gp > newf(1) %45 = 0 (17:04) gp > newf(0) %46 = 1 (17:04) gp > newf(m)=v=vector(m+1);v[1]=1;for(n=1,m+1,v[n]=sum(a=0,n-1,v[a+1]*v[n-a-1]));return(v[m+1]) %47 = (m)->v=vector(m+1);v[1]=1;for(n=1,m+1,v[n]=sum(a=0,n-1,v[a+1]*v[n-a-1]));return(v[m+1]) (17:05) gp > newf(1) *** at top-level: newf(1) *** ^------- *** in function newf: ...v[n]=sum(a=0,n-1,v[a+1]*v[n-a-1]));return(v[m+ *** ^--------------------- *** non-existent component: index < 1 *** Break loop: type 'break' to go back to GP prompt break> break (17:05) gp > newf(m)=v=vector(m+1);v[1]=1;for(n=1,m+1,v[n]=sum(a=0,n-2,v[a+1]*v[n-a-1]));return(v[m+1]) %48 = (m)->v=vector(m+1);v[1]=1;for(n=1,m+1,v[n]=sum(a=0,n-2,v[a+1]*v[n-a-1]));return(v[m+1]) (17:05) gp > newf(1) %49 = 0 (17:05) gp > newf(15) %50 = 0 (17:05) gp > "Exercício - provar que f(n), definido por recursão, é igual com g(n) definido em termos de coefficientes binomiais" %51 = "Exercício - provar que f(n), definido por recursão, é igual com g(n) definido em termos de coefficientes binomiais"