Logging to /Users/s/tmp/pari-26.08 GPRC Done. GP/PARI CALCULATOR Version 2.12.1 (development 25476-78c5f8d2c) i386 running darwin (x86-64/GMP-6.2.0 kernel) 64-bit version compiled: Jun 21 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 (16:13) gp > ?lindep lindep(v,{flag=0}): integral linear dependencies between components of v. flag is optional, and can be 0: default, guess a suitable accuracy, or positive: accuracy to use for the computation, in decimal digits. (16:13) gp > ?algdep algdep(z,k,{flag=0}): algebraic relations up to degree n of z, using lindep([1,z,...,z^(k-1)], flag). (16:15) gp > ??lindep lindep(v,{flag = 0}): finds a small non-trivial integral linear combination between components of v. If none can be found return an empty vector. If v is a vector with real/complex entries we use a floating point (variable precision) LLL algorithm. If flag = 0 the accuracy is chosen internally using a crude heuristic. If flag > 0 the computation is done with an accuracy of flag decimal digits. To get meaningful results in the latter case, the parameter flag should be smaller than the number of correct decimal digits in the input. ? lindep([sqrt(2), sqrt(3), sqrt(2)+sqrt(3)]) %1 = [-1, -1, 1]~ If v is p-adic, flag is ignored and the algorithm LLL-reduces a suitable (dual) lattice. ? lindep([1, 2 + 3 + 3^2 + 3^3 + 3^4 + O(3^5)]) %2 = [1, -2]~ If v is a matrix (or a vector of column vectors, or a vector of row vectors), flag is ignored and the function returns a non trivial kernel vector if one exists, else an empty vector. ? lindep([1,2,3;4,5,6;7,8,9]) %3 = [1, -2, 1]~ ? lindep([[1,0], [2,0]]) %4 = [2, -1]~ ? lindep([[1,0], [0,1]]) %5 = []~ If v contains polynomials or power series over some base field, finds a linear relation with coefficients in the field. ? lindep([x*y, x^2 + y, x^2*y + x*y^2, 1]) %4 = [y, y, -1, -y^2]~ For better control, it is preferable to use t_POL rather than t_SER in the input, otherwise one gets a linear combination which is t-adically small, but not necessarily 0. Indeed, power series are first converted to the minimal absolute accuracy occurring among the entries of v (which can cause some coefficients to be ignored), then truncated to polynomials: /*-- (type RETURN to continue) --*/ ? v = [t^2+O(t^4), 1+O(t^2)]; L=lindep(v) %1 = [1, 0]~ ? v*L %2 = t^2+O(t^4) \\ small but not 0 The library syntax is GEN lindep0(GEN v, long flag). (16:20) gp > ??algdep algdep(z,k,{flag = 0}): z being real/complex, or p-adic, finds a polynomial (in the variable 'x) of degree at most k, with integer coefficients, having z as approximate root. Note that the polynomial which is obtained is not necessarily the "correct" one. In fact it is not even guaranteed to be irreducible. One can check the closeness either by a polynomial evaluation (use subst), or by computing the roots of the polynomial given by algdep (use polroots or polrootspadic). Internally, lindep([1,z,...,z^k], flag) is used. A non-zero value of flag may improve on the default behavior if the input number is known to a huge accuracy, and you suspect the last bits are incorrect: if flag > 0 the computation is done with an accuracy of flag decimal digits; to get meaningful results, the parameter flag should be smaller than the number of correct decimal digits in the input. But default values are usually sufficient, so try without flag first: ? \p200 ? z = 2^(1/6)+3^(1/5); ? algdep(z, 30); \\ right in 280ms ? algdep(z, 30, 100); \\ wrong in 169ms ? algdep(z, 30, 170); \\ right in 288ms ? algdep(z, 30, 200); \\ wrong in 320ms ? \p250 ? z = 2^(1/6)+3^(1/5); \\ recompute to new, higher, accuracy ! ? algdep(z, 30); \\ right in 329ms ? algdep(z, 30, 200); \\ right in 324ms ? \p500 ? algdep(2^(1/6)+3^(1/5), 30); \\ right in 677ms ? \p1000 ? algdep(2^(1/6)+3^(1/5), 30); \\ right in 1.5s The changes in realprecision only affect the quality of the initial approximation to 2^{1/6} + 3^{1/5}, algdep itself uses exact operations. The size of its operands depend on the accuracy of the input of course: more accurate input means slower operations. Proceeding by increments of 5 digits of accuracy, algdep with default flag produces its first correct result at 195 digits, and from then on a steady stream of correct results: \\ assume T contains the correct result, for comparison /*-- (type RETURN to continue) --*/ forstep(d=100, 250, 5, localprec(d);\ print(d, " ", algdep(2^(1/6)+3^(1/5),30) == T)) The above example is the test case studied in a 2000 paper by Borwein and Lisonek: Applications of integer relation algorithms, Discrete Math., 217, p. 65--82. The version of PARI tested there was 1.39, which succeeded reliably from precision 265 on, in about 200 as much time as the current version. The library syntax is GEN algdep0(GEN z, long k, long flag). Also available is GEN algdep(GEN z, long k) (flag = 0). (16:21) gp > \p realprecision = 38 significant digits (16:21) gp > cos(2*Pi) %1 = 1.0000000000000000000000000000000000000 (16:21) gp > cos(2*Pi/3) %2 = -0.50000000000000000000000000000000000000 (16:21) gp > cos(2*Pi/5) %3 = 0.30901699437494742410229341718281905886 (16:21) gp > algdep(cos(2*Pi/5),1) %4 = 806515533049393*x - 249227005939632 (16:21) gp > algdep(cos(2*Pi/5),1,100) %5 = 170141183460469231731687303715884105728*x - 52576517132350718291434092471003083277 (16:22) gp > algdep(cos(2*Pi/5),1,200) %6 = 170141183460469231731687303715884105728*x - 52576517132350718291434092471003083277 (16:22) gp > algdep(cos(2*Pi/5),1,600) %7 = 170141183460469231731687303715884105728*x - 52576517132350718291434092471003083277 (16:22) gp > \p realprecision = 38 significant digits (16:22) gp > \p100 realprecision = 115 significant digits (100 digits displayed) (16:22) gp > algdep(cos(2*Pi/5),1) %8 = 13734520083255583906104114706164126578641192042*x - 4244200115309993198876969489421897548446236915 (16:22) gp > algdep(cos(2*Pi/5),2) %9 = 4*x^2 + 2*x - 1 (16:22) gp > \p200 realprecision = 211 significant digits (200 digits displayed) (16:22) gp > algdep(cos(2*Pi/5),2) %10 = 4*x^2 + 2*x - 1 (16:23) gp > algdep(cos(2*Pi/6),2) %11 = 2*x^2 - x (16:23) gp > algdep(cos(2*Pi/7),2) %12 = 136433121564103176244833901736775726072777070111782375074*x^2 + 128120269478116810239225516320614647194857211680717711133*x - 132918629396540374603927387992393424096394564047001538627 (16:23) gp > algdep(cos(2*Pi/7),3) %13 = 8*x^3 + 4*x^2 - 4*x - 1 (16:23) gp > ?eulerphi eulerphi(x): Euler's totient function of x. (16:24) gp > ??eulerphi eulerphi(x): Euler's phi (totient) function of the integer |x|, in other words |(Z/xZ)^*|. ? eulerphi(40) %1 = 16 According to this definition we let phi(0) := 2, since Z^ *= {-1,1}; this is consistent with znstar(0): we have znstar(n).no = eulerphi(n) for all n\inZ. The library syntax is GEN eulerphi(GEN x). (16:24) gp > algdep(cos(2*Pi/8),2) %14 = 2*x^2 - 1 (16:24) gp > algdep(cos(2*Pi/9),2) %15 = 11336364673273093346920230790514536859159865396027352765*x^2 - 52707388799883443992029012121480195239389664519413336364*x + 33723750431384806739844260470731187600573063857488263449 (16:24) gp > algdep(cos(2*Pi/9),3) %16 = 8*x^3 - 6*x + 1 (16:24) gp > eulerphi(9) %17 = 6 (16:24) gp > eulerphi(12) %18 = 4 (16:25) gp > depcos(n)=algdep(cos(2*Pi/n),eulerphi(n)/2) %19 = (n)->algdep(cos(2*Pi/n),eulerphi(n)/2) (16:25) gp > depcos(1) *** at top-level: depcos(1) *** ^--------- *** in function depcos: algdep(cos(2*Pi/n),eulerphi(n)/2) *** ^-------------- *** incorrect type in gtos [integer expected] (t_FRAC). *** Break loop: type 'break' to go back to GP prompt break> break (16:25) gp > depcos(2) *** at top-level: depcos(2) *** ^--------- *** in function depcos: algdep(cos(2*Pi/n),eulerphi(n)/2) *** ^-------------- *** incorrect type in gtos [integer expected] (t_FRAC). *** Break loop: type 'break' to go back to GP prompt break> break (16:26) gp > depcos(3) %20 = 2*x + 1 (16:26) gp > depcos(4) %21 = x (16:26) gp > depcos(5) %22 = 4*x^2 + 2*x - 1 (16:26) gp > depcos(6) %23 = 2*x - 1 (16:26) gp > depcos(7) %24 = 8*x^3 + 4*x^2 - 4*x - 1 (16:26) gp > depcos(8) %25 = 2*x^2 - 1 (16:26) gp > depcos(9) %26 = 8*x^3 - 6*x + 1 (16:26) gp > depcos(10) %27 = 4*x^2 - 2*x - 1 (16:26) gp > depcos(11) %28 = 32*x^5 + 16*x^4 - 32*x^3 - 12*x^2 + 6*x + 1 (16:26) gp > depcos(12) %29 = 4*x^2 - 3 (16:26) gp > ?factor factor(x,{D}): factorization of x over domain D. If x and D are both integers, return partial factorization, using primes < D. (16:26) gp > factor(%28) %30 = [32*x^5 + 16*x^4 - 32*x^3 - 12*x^2 + 6*x + 1 1] (16:26) gp > depcos(n)=factor(algdep(cos(2*Pi/n),eulerphi(n)/2)) %31 = (n)->factor(algdep(cos(2*Pi/n),eulerphi(n)/2)) (16:27) gp > lindep([1,cos(2*Pi/5),cos(2*Pi/5)^2]) %32 = [1, -2, -4]~ (16:27) gp > lindep([1,cos(2*Pi/5),cos(4*Pi/5)]) %33 = [1, 2, 2]~ (16:27) gp > depcos(n)=factor(algdep(cos(2*Pi/n),eulerphi(n)/2)) %34 = (n)->factor(algdep(cos(2*Pi/n),eulerphi(n)/2)) (16:28) gp > depcos(12) %35 = [4*x^2 - 3 1] (16:28) gp > depcos(13) %36 = [64*x^6 + 32*x^5 - 80*x^4 - 32*x^3 + 24*x^2 + 6*x - 1 1] (16:28) gp > depcos(17) %37 = [256*x^8 + 128*x^7 - 448*x^6 - 192*x^5 + 240*x^4 + 80*x^3 - 40*x^2 - 8*x + 1 1] (16:28) gp > depcos(14) %38 = [8*x^3 - 4*x^2 - 4*x + 1 1] (16:28) gp > depcos(15) %39 = [16*x^4 - 8*x^3 - 16*x^2 + 8*x + 1 1] (16:28) gp > depcos(16) %40 = [8*x^4 - 8*x^2 + 1 1] (16:28) gp > depcos(17) %41 = [256*x^8 + 128*x^7 - 448*x^6 - 192*x^5 + 240*x^4 + 80*x^3 - 40*x^2 - 8*x + 1 1] (16:28) gp > depcos(18) %42 = [8*x^3 - 6*x - 1 1] (16:28) gp > (algdep(cos(2*Pi/n),eulerphi(n)/2)) *** at top-level: algdep(cos(2*Pi/n),eulerphi(n)/2) *** ^-------------------------- *** cos: domain error in cos: valuation < 0 *** Break loop: type 'break' to go back to GP prompt break> break (16:29) gp > depcos(n)=(algdep(cos(2*Pi/n),eulerphi(n)/2)) %43 = (n)->algdep(cos(2*Pi/n),eulerphi(n)/2) (16:29) gp > depcos(17) %44 = 256*x^8 + 128*x^7 - 448*x^6 - 192*x^5 + 240*x^4 + 80*x^3 - 40*x^2 - 8*x + 1 (16:29) gp > polgalois(%) *** at top-level: polgalois(%) *** ^------------ *** polgalois: error opening galois file: `/usr/local/share/pari/galdata/COS8_50_47'. *** Break loop: type 'break' to go back to GP prompt break> break (16:30) gp > depcos(9) %45 = 8*x^3 - 6*x + 1 (16:30) gp > polgalois(%) %46 = [3, 1, 1, "A3"] (16:30) gp > depcos(5) %47 = 4*x^2 + 2*x - 1 (16:30) gp > algdep(9) *** too few arguments: algdep(9) *** ^- (16:53) gp > depcos(9) %48 = 8*x^3 - 6*x + 1