S1 Logging to /Users/s/tmp/pari-28.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. parisizemax = 900001792, primelimit = 1000000 (15:12) gp > \rdiv.gp (15:12) gp > myfloor(5.5+7*I) %3 = 5 + 7*I (15:12) gp > myfloor(5.5+exp(5)*I) %4 = 5 + 148*I (15:12) gp > mydiv(10+15*I,3+2*I) %5 = [4 + I, (-3 - 2*I)*w + (10 + 15*I)] (15:12) gp > (3+2*I)*(4+I) %6 = 10 + 11*I ---------------------------------------------------- S2 (15:15) gp > \rdiv.gp (15:15) gp > ?mydiv mydiv = (a,b)->z=a/b;d=myfloor(z);r=a-b*d;return([d,r]) (15:15) gp > ?myfloor myfloor = (z)->floor(real(z))+I*floor(imag(z)) (15:15) gp > mydiv(10+17*I,2+3*I) %3 = [5, 2*I] (15:15) gp > mydiv(10+17*I,3+2*I) %4 = [4 + 2*I, 2 + 3*I] (15:15) gp > mydiv(10+17*I,1+I) %5 = [13 + 3*I, I] (15:15) gp > (1+I)*(13+3*I)+I %6 = 10 + 17*I (15:16) gp > abs(10+17*I) %7 = 19.723082923316019968063999083247803800 (15:16) gp > abs(1+I) %8 = 1.4142135623730950488016887242096980786 (15:16) gp > abs(1+I)^2 %9 = 2.0000000000000000000000000000000000000 (15:16) gp > abs(I) %10 = 1 --------------------------------------------------------- S3 (15:24) gp > \rdiv.gp *** too many arguments: ...: todos os vizinhos de ", *** a,"com respeito de ", *** ^--------------------- (15:24) gp > ?mydiv mydiv = (a,b)->z=a/b;d=myfloor(z);r=a-b*d;return([d,r]) --------------------------------------------------------- S4 (15:25) gp > \rdiv.gp (15:25) gp > ?mydiv2 mydiv2 = (a,b)->if(abs(a) mydiv2(10+I,3+I) %4 = [3, 1 - 2*I] (15:25) gp > mydiv(10+I,3+I) %5 = [3 - I, I] (15:25) gp > abs(1-2(I)) *** at top-level: abs(1-2(I)) *** ^----- *** not a function in function call *** Break loop: type 'break' to go back to GP prompt break> break (15:25) gp > abs(1-2*I) %6 = 2.2360679774997896964091736687312762354 (15:25) gp > abs(3+I)^2 %7 = 10.000000000000000000000000000000000000 (15:26) gp > ?norm norm(x): norm of x. (15:26) gp > norm(3+I) %8 = 10 --------------------------------------------------------- S5 (15:26) gp > \rdiv.gp (15:26) gp > ?mydiv mydiv = (a,b)->z=a/b;d=myfloor(z);r=a-b*d;return([d,r]) (15:26) gp > ?mydiv2 mydiv2 = (a,b)->if(norm(a) mydiv(10+I,3+I) %4 = [3 - I, I] (15:27) gp > mydiv2(10+I,3+I) %5 = [3, 1 - 2*I] (15:27) gp > norm(3+I) %6 = 10 (15:27) gp > norm(1-2*I) %7 = 5 (15:27) gp > (3-I)*(3+I)+I %8 = 10 + I (15:27) gp > 3*(3+I)+(1-2*I) %9 = 10 + I (15:27) gp > norm(I) %10 = 1 (15:28) gp > norm(1-2*I) %11 = 5 (15:28) gp > norm(3+I) %12 = 10 (15:28) gp > "Então ambos algoritmos são OK, mas resulto de primeiro neste caso é um pouco melhor." %13 = "Então ambos algoritmos são OK, mas resulto de primeiro neste caso é um pouco melhor." (15:29) gp > ?gcd gcd(x,{y}): greatest common divisor of x and y. (15:29) gp > gcd(10+2*I,6+8*I) %14 = 2 --------------------------------------------------------- S6 (15:32) gp > \rdiv.gp (15:32) gp > X=3+4*I %5 = 3 + 4*I (15:32) gp > gcd(X,5) %6 = 2 + I (15:32) gp > Y=5 %7 = 5 (15:32) gp > gcd(3+4*I,5) %8 = 2 + I (15:32) gp > mygcd(3+4*I,5) *** [...] at: ...(norm(b)>=norm(a),return(mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: ...(norm(b)>=norm(a),return( *** mygcd(b,a)));if(b==0, *** ^--------------------- *** in function mygcd: *** if(norm(b)>=norm(a),return(mygcd(b,a)));if(b== *** ^---------------------------------------------- *** _void_if: deep recursion. *** Break loop: type 'break' to go back to GP prompt --------------------------------------------------------- S7 (15:33) gp > \rdiv.gp (15:34) gp > gcd(3+4*I,5) %5 = 2 + I (15:34) gp > mygcd(3+4*I,5) *** at top-level: mygcd(3+4*I,5) *** ^-------------- *** in function mygcd: ...f(b==0,return(a));return( *** mygcd(b,mydiv(a,b))) *** ^-------------------- *** in function mygcd: if(norm(b) *** >norm(a),return(mygcd(b,a)));if(b==0 *** ^------------------------------------ *** _>_: forbidden comparison t_VEC (2 elts) , t_INT. *** Break loop: type 'break' to go back to GP prompt --------------------------------------------------------- S8 (15:36) gp > \rdiv.gp (15:36) gp > mygcd(3+4*I,5) %5 = -1 + 2*I (15:36) gp > gcd(3+4*I,5) %6 = 2 + I (15:36) gp > mygcd(3+4*I,5)/gcd(3+4*I,5) %7 = I (15:37) gp > "Então maximo divisor comum é quase mesmo, mas a gente pode multiplicar ele com um constante inversivel arbitrario" %8 = "Então maximo divisor comum é quase mesmo, mas a gente pode multiplicar ele com um constante inversivel arbitrario" (15:40) gp > (3+4*I)/(2+I) %9 = 2 + I (15:40) gp > 5/(2+I) %10 = 2 - I (15:40) gp > gcd(2+I,2-I) %11 = 1 (15:40) gp > mygcd(2+I,2-I) %12 = I