Logging to /Users/s/tmp/pari-14.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 (12:25) gp > ??permorder permorder(x): Given a permutation x on n elements, return its order. ? p = Vecsmall([3,1,4,2,5]); ? p^2 %2 = Vecsmall([4,3,2,1,5]) ? p^4 %3 = Vecsmall([1,2,3,4,5]) ? permorder(p) %4 = 4 The library syntax is long permorder(GEN x). Logging to /Users/s/tmp/pari-14.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 = 400000000, primelimit = 1000000 (12:26) gp > ??forperm forperm(a,p,seq): Evaluates seq, where the formal variable p goes through some permutations given by a t_VECSMALL. If a is a positive integer then P goes through the permutations of {1, 2, ..., a} in lexicographic order and if a is a small vector then p goes through the (multi)permutations lexicographically larger than or equal to a. ? forperm(3, p, print(p)) Vecsmall([1, 2, 3]) Vecsmall([1, 3, 2]) Vecsmall([2, 1, 3]) Vecsmall([2, 3, 1]) Vecsmall([3, 1, 2]) Vecsmall([3, 2, 1]) When a is itself a t_VECSMALL or a t_VEC then p iterates through multipermutations ? forperm([2,1,1,3], p, print(p)) Vecsmall([2, 1, 1, 3]) Vecsmall([2, 1, 3, 1]) Vecsmall([2, 3, 1, 1]) Vecsmall([3, 1, 1, 2]) Vecsmall([3, 1, 2, 1]) Vecsmall([3, 2, 1, 1]) Logging to /Users/s/tmp/pari-14.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 = 400000000, primelimit = 1000000 Logging to /Users/s/tmp/pari-14.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 = 400000000, primelimit = 1000000 (12:30) gp > ??gcd gcd(x,{y}): Creates the greatest common divisor of x and y. If you also need the u and v such that x*u + y*v = gcd(x,y), use the gcdext function. x and y can have rather quite general types, for instance both rational numbers. If y is omitted and x is a vector, returns the gcd of all components of x, i.e. this is equivalent to content(x). When x and y are both given and one of them is a vector/matrix type, the GCD is again taken recursively on each component, but in a different way. If y is a vector, resp. matrix, then the result has the same type as y, and components equal to gcd(x, y[i]), resp. gcd(x, y[,i]). Else if x is a vector/matrix the result has the same type as x and an analogous definition. Note that for these types, gcd is not commutative. The algorithm used is a naive Euclid except for the following inputs: * integers: use modified right-shift binary ("plus-minus" variant). * univariate polynomials with coefficients in the same number field (in particular rational): use modular gcd algorithm. * general polynomials: use the subresultant algorithm if coefficient explosion is likely (non modular coefficients). If u and v are polynomials in the same variable with inexact coefficients, their gcd is defined to be scalar, so that ? a = x + 0.0; gcd(a,a) %1 = 1 ? b = y*x + O(y); gcd(b,b) %2 = y ? c = 4*x + O(2^3); gcd(c,c) %3 = 4 A good quantitative check to decide whether such a gcd "should be" non-trivial, is to use polresultant: a value close to 0 means that a small deformation of the inputs has non-trivial gcd. You may also use gcdext, which does try to compute an approximate gcd d and provides u, v to check whether u x + v y is close to d. /*-- (type RETURN to continue) --*/ The library syntax is GEN ggcd0(GEN x, GEN y = NULL). Also available are GEN ggcd(GEN x, GEN y), if y is not NULL, and GEN content(GEN x), if y = NULL. (12:30) gp > ?content content(x,{D}): gcd of all the components of x, when this makes sense. (12:30) gp > ??content content(x,{D}): Computes the gcd of all the coefficients of x, when this gcd makes sense. This is the natural definition if x is a polynomial (and by extension a power series) or a vector/matrix. This is in general a weaker notion than the ideal generated by the coefficients: ? content(2*x+y) %1 = 1 \\ = gcd(2,y) over Q[y] If x is a scalar, this simply returns the absolute value of x if x is rational (t_INT or t_FRAC), and either 1 (inexact input) or x (exact input) otherwise; the result should be identical to gcd(x, 0). The content of a rational function is the ratio of the contents of the numerator and the denominator. In recursive structures, if a matrix or vector coefficient x appears, the gcd is taken not with x, but with its content: ? content([ [2], 4*matid(3) ]) %1 = 2 The content of a t_VECSMALL is computed assuming the entries are signed integers. The optional argument D allows to control over which ring we compute and get a more predictable behaviour: * 1: we only consider the underlying Q-structure and the denominator is a (positive) rational number * a simple variable, say 'x: all entries are considered as rational functions in K(x) for some field K and the content is an element of K. ? f = x + 1/y + 1/2; ? content(f) \\ as a t_POL in x %2 = 1/(2*y) ? content(f, 1) \\ Q-content %3 = 1/2 ? content(f, y) \\ as a rational function in y %4 = 1/2 /*-- (type RETURN to continue) --*/ ? g = x^2*y + y^2*x; ? content(g, x) %6 = y ? content(g, y) %7 = x The library syntax is GEN content0(GEN x, GEN D = NULL). (12:30) gp > content(6*x+10) %1 = 2 (12:30) gp > content(2/3+x/60) %2 = 1/60 (12:31) gp > content(2/3+x/4) %3 = 1/12 Logging to /Users/s/tmp/pari-14.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:08) gp > ??gcd gcd(x,{y}): Creates the greatest common divisor of x and y. If you also need the u and v such that x*u + y*v = gcd(x,y), use the gcdext function. x and y can have rather quite general types, for instance both rational numbers. If y is omitted and x is a vector, returns the gcd of all components of x, i.e. this is equivalent to content(x). When x and y are both given and one of them is a vector/matrix type, the GCD is again taken recursively on each component, but in a different way. If y is a vector, resp. matrix, then the result has the same type as y, and components equal to gcd(x, y[i]), resp. gcd(x, y[,i]). Else if x is a vector/matrix the result has the same type as x and an analogous definition. Note that for these types, gcd is not commutative. The algorithm used is a naive Euclid except for the following inputs: * integers: use modified right-shift binary ("plus-minus" variant). * univariate polynomials with coefficients in the same number field (in particular rational): use modular gcd algorithm. * general polynomials: use the subresultant algorithm if coefficient explosion is likely (non modular coefficients). If u and v are polynomials in the same variable with inexact coefficients, their gcd is defined to be scalar, so that ? a = x + 0.0; gcd(a,a) %1 = 1 ? b = y*x + O(y); gcd(b,b) %2 = y ? c = 4*x + O(2^3); gcd(c,c) %3 = 4 A good quantitative check to decide whether such a gcd "should be" non-trivial, is to use polresultant: a value close to 0 means that a small deformation of the inputs has non-trivial gcd. You may also use gcdext, which does try to compute an approximate gcd d and provides u, v to check whether u x + v y is close to d. /*-- (type RETURN to continue) --*/ The library syntax is GEN ggcd0(GEN x, GEN y = NULL). Also available are GEN ggcd(GEN x, GEN y), if y is not NULL, and GEN content(GEN x), if y = NULL. Logging to /Users/s/tmp/pari-14.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:11) gp > ?gcd gcd(x,{y}): greatest common divisor of x and y. (15:11) gp > ??gcd gcd(x,{y}): Creates the greatest common divisor of x and y. If you also need the u and v such that x*u + y*v = gcd(x,y), use the gcdext function. x and y can have rather quite general types, for instance both rational numbers. If y is omitted and x is a vector, returns the gcd of all components of x, i.e. this is equivalent to content(x). When x and y are both given and one of them is a vector/matrix type, the GCD is again taken recursively on each component, but in a different way. If y is a vector, resp. matrix, then the result has the same type as y, and components equal to gcd(x, y[i]), resp. gcd(x, y[,i]). Else if x is a vector/matrix the result has the same type as x and an analogous definition. Note that for these types, gcd is not commutative. The algorithm used is a naive Euclid except for the following inputs: * integers: use modified right-shift binary ("plus-minus" variant). * univariate polynomials with coefficients in the same number field (in particular rational): use modular gcd algorithm. * general polynomials: use the subresultant algorithm if coefficient explosion is likely (non modular coefficients). If u and v are polynomials in the same variable with inexact coefficients, their gcd is defined to be scalar, so that ? a = x + 0.0; gcd(a,a) %1 = 1 ? b = y*x + O(y); gcd(b,b) %2 = y ? c = 4*x + O(2^3); gcd(c,c) %3 = 4 A good quantitative check to decide whether such a gcd "should be" non-trivial, is to use polresultant: a value close to 0 means that a small deformation of the inputs has non-trivial gcd. You may also use gcdext, which does try to compute an approximate gcd d and provides u, v to check whether u x + v y is close to d. /*-- (type RETURN to continue) --*/ The library syntax is GEN ggcd0(GEN x, GEN y = NULL). Also available are GEN ggcd(GEN x, GEN y), if y is not NULL, and GEN content(GEN x), if y = NULL. (15:12) gp > ?gcdext gcdext(x,y): returns [u,v,d] such that d=gcd(x,y) and u*x+v*y=d. (15:12) gp > ??gcdext gcdext(x,y): Returns [u,v,d] such that d is the gcd of x,y, x*u+y*v = gcd(x,y), and u and v minimal in a natural sense. The arguments must be integers or polynomials. ? [u, v, d] = gcdext(32,102) %1 = [16, -5, 2] ? d %2 = 2 ? gcdext(x^2-x, x^2+x-2) %3 = [-1/2, 1/2, x - 1] If x,y are polynomials in the same variable and inexact coefficients, then compute u,v,d such that x*u+y*v = d, where d approximately divides both and x and y; in particular, we do not obtain gcd(x,y) which is defined to be a scalar in this case: ? a = x + 0.0; gcd(a,a) %1 = 1 ? gcdext(a,a) %2 = [0, 1, x + 0.E-28] ? gcdext(x-Pi, 6*x^2-zeta(2)) %3 = [-6*x - 18.8495559, 1, 57.5726923] For inexact inputs, the output is thus not well defined mathematically, but you obtain explicit polynomials to check whether the approximation is close enough for your needs. The library syntax is GEN gcdext0(GEN x, GEN y). (15:12) gp > ???gcdext bezout gcd gcdext (15:12) gp > ?bezout bezout(x,y): deprecated alias for gcdext. (15:13) gp > ??bezout bezout(x,y): Deprecated alias for gcdext The library syntax is GEN gcdext0(GEN x, GEN y). (15:13) gp > gcd(10,15) %1 = 5 (15:13) gp > gcdext(24,60) %2 = [-2, 1, 12] (15:13) gp > 24*-2+60*1 %3 = 12 (15:13) gp > q=z^5-Mod(1,12) %4 = z^5 + Mod(11, 12) (16:24) gp > a=1001 %5 = 1001 (16:24) gp > ?subst subst(x,y,z): in expression x, replace the variable y by the expression z. (16:24) gp > subst(q,x,a) %6 = z^5 + Mod(11, 12) (16:24) gp > q=x^5-Mod(1,12) %7 = x^5 + Mod(11, 12) (16:24) gp > subst(q,x,a) %8 = Mod(4, 12) (16:24) gp > 1001^5-1 %9 = 1005010010005000 (16:24) gp > %/12 %10 = 251252502501250/3 (16:25) gp > 1001^5-1 %11 = 1005010010005000 (16:25) gp > (1001^5-1-4)/12 %12 = 83750834167083 (16:25) gp > Mod(1005010010005000,12) %13 = Mod(4, 12) (16:25) gp > q %14 = x^5 + Mod(11, 12) (16:25) gp > q2=z^3+7 %15 = z^3 + 7 (16:25) gp > q2=x^3+7 %16 = x^3 + 7 (16:25) gp > subst(q2,x,a) %17 = 1003003008 (16:25) gp > subst(q,x,a) %18 = Mod(4, 12) (16:26) gp > subst(q,x,a)+subst(q2,x,a) %19 = Mod(4, 12) (16:26) gp > subst(q+q2,x,a) %20 = Mod(4, 12) (16:26) gp > subst(q,x,a)*subst(q2,x,a) %21 = Mod(0, 12) (16:26) gp > subst(q*q2,x,a) %22 = Mod(0, 12) (16:26) gp > q*q2 %23 = Mod(1, 12)*x^8 + Mod(7, 12)*x^5 + Mod(11, 12)*x^3 + Mod(5, 12) (16:26) gp > a %24 = 1001 (16:26) gp > Mod(a,12) %25 = Mod(5, 12) (16:27) gp > liftint(%23) %26 = x^8 + 7*x^5 + 11*x^3 + 5 (16:27) gp > subst(x^8+7*x^5+11*x^3+5,x,Mod(5,12)) %27 = Mod(0, 12) (16:27) gp > subst(x^8+7*x^5+11*x^3+5,x,1001) %28 = 1008028063105137131076024 (16:27) gp > Mod(%,12) %29 = Mod(0, 12) (16:27) gp > "E dito que substituição é um morfismo dos anéis, soma var para soma, produto para produto, diferençã para diferença" %30 = "E dito que substituição é um morfismo dos anéis, soma var para soma, produto para produto, diferençã para diferença" (16:28) gp > Q=x^3+3*x^2+3*x %31 = x^3 + 3*x^2 + 3*x (16:43) gp > R=x^2-1 %32 = x^2 - 1 (16:43) gp > subst(Q,x,R) %33 = x^6 - 1 (16:43) gp > subst(Q,x,x+1) %34 = x^3 + 6*x^2 + 12*x + 7 (16:43) gp > subst(Q,x,x-1) %35 = x^3 - 1 (16:43) gp > (x+1)^3-1 %36 = x^3 + 3*x^2 + 3*x (16:43) gp > (x+1)^3-1==Q %37 = 1 (16:44) gp > Q=(x+1)^13 %38 = x^13 + 13*x^12 + 78*x^11 + 286*x^10 + 715*x^9 + 1287*x^8 + 1716*x^7 + 1716*x^6 + 1287*x^5 + 715*x^4 + 286*x^3 + 78*x^2 + 13*x + 1 (16:44) gp > Qr=Mod(Q,13) %39 = Mod(1, 13)*x^13 + Mod(1, 13) (16:44) gp > subst(Qr,x,x-1) %40 = Mod(1, 13)*x^13 (16:44) gp > eulerphi(24) %41 = 8 (16:59) gp > Q=z^2-Mod(1,24) %42 = z^2 + Mod(23, 24) (16:59) gp > roots(Q) *** at top-level: roots(Q) *** ^-------- *** polroots: incorrect type in roots (t_INTMOD). *** Break loop: type 'break' to go back to GP prompt break> break (16:59) gp > subst(Q,z,1) %43 = Mod(0, 24) (16:59) gp > subst(Q,z,5) %44 = Mod(0, 24) (16:59) gp > subst(Q,z,7) %45 = Mod(0, 24) (16:59) gp > Q=x^2-Mod(1,24) %46 = x^2 + Mod(23, 24) (16:59) gp > subst(Q,x,y+1) %47 = y^2 + 2*y (17:00) gp > subst(Q,x,y+1)/y %48 = y + 2 (17:00) gp > subst(subst(Q,x,y+1)/y,y,x-1) %49 = x + 1 (17:00) gp > Divv(QQ,a)=subst(subst(QQ,x,y+a)/y,y,x-a) %50 = (QQ,a)->subst(subst(QQ,x,y+a)/y,y,x-a) (17:00) gp > Divv(x^2-Mod(1,24),1) %51 = x + 1 (17:01) gp > Divv(x^2-Mod(1,24),5) %52 = x + 5 (17:01) gp > Divv(x^2-Mod(1,24),5) %53 = x + 5 (17:02) gp > Divv(x^13-x,Mod(1,13)) %54 = Mod(1, 13)*x^12 + Mod(1, 13)*x^11 + Mod(1, 13)*x^10 + Mod(1, 13)*x^9 + Mod(1, 13)*x^8 + Mod(1, 13)*x^7 + Mod(1, 13)*x^6 + Mod(1, 13)*x^5 + Mod(1, 13)*x^4 + Mod(1, 13)*x^3 + Mod(1, 13)*x^2 + Mod(1, 13)*x (17:02) gp > Divv(%,Mod(2,13)) %55 = Mod(1, 13)*x^11 + Mod(3, 13)*x^10 + Mod(7, 13)*x^9 + Mod(2, 13)*x^8 + Mod(5, 13)*x^7 + Mod(11, 13)*x^6 + Mod(10, 13)*x^5 + Mod(8, 13)*x^4 + Mod(4, 13)*x^3 + Mod(9, 13)*x^2 + Mod(6, 13)*x (17:02) gp > Divv(%,Mod(8,13)) %56 = Mod(1, 13)*x^10 + Mod(11, 13)*x^9 + Mod(4, 13)*x^8 + Mod(8, 13)*x^7 + Mod(4, 13)*x^6 + Mod(4, 13)*x^5 + Mod(3, 13)*x^4 + Mod(6, 13)*x^3 + Mod(9, 13)*x (17:02) gp > liftint(%56) %57 = x^10 + 11*x^9 + 4*x^8 + 8*x^7 + 4*x^6 + 4*x^5 + 3*x^4 + 6*x^3 + 9*x (17:03) gp > %57*(x-8)*(x-2)*(x-1) %58 = x^13 - 91*x^11 + 234*x^10 - 156*x^9 + 104*x^8 - 65*x^7 + 13*x^6 - 52*x^5 + 117*x^4 - 195*x^3 + 234*x^2 - 144*x (17:03) gp > Mod(%,13) %59 = Mod(1, 13)*x^13 + Mod(12, 13)*x (17:03) gp > lift(%) %60 = x^13 + 12*x