gcd.log 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. Sat Jun 29 13:40:23 PDT 1991
  2. REDUCE 3.4, 15-Jul-91 ...
  3. 1: 1:
  4. 2: 2:
  5. 3: 3: COMMENT Greatest Common Divisor Test Suite;
  6. % The following examples were introduced in Moses, J. and Yun, D.Y.Y.,
  7. % "The EZ GCD Algorithm", Proc. ACM 73 (1973) 159-166, and considered
  8. % further in Hearn, A.C., "Non-modular Computation of Polynomial GCD's
  9. % Using Trial Division", Proc. EUROSAM 79, 227-239, 72, published as
  10. % Lecture Notes on Comp. Science, # 72, Springer-Verlag, Berlin, 1979.
  11. on gcd;
  12. % The following is the best setting for this file.
  13. on ezgcd;
  14. % In systems that have the heugcd code, the following is also a
  15. % possibility, although not all examples complete in a reasonable time.
  16. % load heugcd; on heugcd;
  17. % The final alternative is to use neither ezgcd nor heugcd. In that case,
  18. % most examples take excessive amounts of computer time.
  19. share n;
  20. operator xx;
  21. % Case 1.
  22. for n := 2:5
  23. do write gcd(((for i:=1:n sum xx(i))-1)*((for i:=1:n sum xx(i)) + 2),
  24. ((for i:=1:n sum xx(i))+1)
  25. *(-3xx(2)*xx(1)**2+xx(2)**2-1)**2);
  26. 1
  27. 1
  28. 1
  29. 1
  30. % Case 2.
  31. let d = (for i:=1:n sum xx(i)**n) + 1;
  32. for n := 2:7 do write gcd(d*((for i:=1:n sum xx(i)**n) - 2),
  33. d*((for i:=1:n sum xx(i)**n) + 2));
  34. 2 2
  35. XX(2) + XX(1) + 1
  36. 3 3 3
  37. XX(3) + XX(2) + XX(1) + 1
  38. 4 4 4 4
  39. XX(4) + XX(3) + XX(2) + XX(1) + 1
  40. 5 5 5 5 5
  41. XX(5) + XX(4) + XX(3) + XX(2) + XX(1) + 1
  42. 6 6 6 6 6 6
  43. XX(6) + XX(5) + XX(4) + XX(3) + XX(2) + XX(1) + 1
  44. 7 7 7 7 7 7 7
  45. XX(7) + XX(6) + XX(5) + XX(4) + XX(3) + XX(2) + XX(1) + 1
  46. for n := 2:7 do write gcd(d*((for i:=1:n sum xx(i)**n) - 2),
  47. d*((for i:=1:n sum xx(i)**(n-1)) + 2));
  48. 2 2
  49. XX(2) + XX(1) + 1
  50. 3 3 3
  51. XX(3) + XX(2) + XX(1) + 1
  52. 4 4 4 4
  53. XX(4) + XX(3) + XX(2) + XX(1) + 1
  54. 5 5 5 5 5
  55. XX(5) + XX(4) + XX(3) + XX(2) + XX(1) + 1
  56. 6 6 6 6 6 6
  57. XX(6) + XX(5) + XX(4) + XX(3) + XX(2) + XX(1) + 1
  58. 7 7 7 7 7 7 7
  59. XX(7) + XX(6) + XX(5) + XX(4) + XX(3) + XX(2) + XX(1) + 1
  60. % Case 3.
  61. let d = xx(2)**2*xx(1)**2 + (for i := 3:n sum xx(i)**2) + 1;
  62. for n := 2:5
  63. do write gcd(d*(xx(2)*xx(1) + (for i:=3:n sum xx(i)) + 2)**2,
  64. d*(xx(1)**2-xx(2)**2 + (for i:=3:n sum xx(i)**2) - 1));
  65. 2 2
  66. XX(2) *XX(1) + 1
  67. 2 2 2
  68. XX(3) + XX(2) *XX(1) + 1
  69. 2 2 2 2
  70. XX(4) + XX(3) + XX(2) *XX(1) + 1
  71. 2 2 2 2 2
  72. XX(5) + XX(4) + XX(3) + XX(2) *XX(1) + 1
  73. % Case 4.
  74. let u = xx(1) - xx(2)*xx(3) + 1,
  75. v = xx(1) - xx(2) + 3xx(3);
  76. gcd(u*v**2,v*u**2);
  77. 2 2
  78. 3*XX(3) *XX(2) - XX(3)*XX(2) + XX(3)*XX(2)*XX(1) - 3*XX(3)*XX(1)
  79. 2
  80. - 3*XX(3) + XX(2)*XX(1) + XX(2) - XX(1) - XX(1)
  81. gcd(u*v**3,v*u**3);
  82. 2 2
  83. 3*XX(3) *XX(2) - XX(3)*XX(2) + XX(3)*XX(2)*XX(1) - 3*XX(3)*XX(1)
  84. 2
  85. - 3*XX(3) + XX(2)*XX(1) + XX(2) - XX(1) - XX(1)
  86. gcd(u*v**4,v*u**4);
  87. 2 2
  88. 3*XX(3) *XX(2) - XX(3)*XX(2) + XX(3)*XX(2)*XX(1) - 3*XX(3)*XX(1)
  89. 2
  90. - 3*XX(3) + XX(2)*XX(1) + XX(2) - XX(1) - XX(1)
  91. gcd(u**2*v**4,v**2*u**4);
  92. 4 2 3 3 3 2
  93. 9*XX(3) *XX(2) - 6*XX(3) *XX(2) + 6*XX(3) *XX(2) *XX(1)
  94. 3 3 2 4
  95. - 18*XX(3) *XX(2)*XX(1) - 18*XX(3) *XX(2) + XX(3) *XX(2)
  96. 2 3 2 2 2
  97. - 2*XX(3) *XX(2) *XX(1) + XX(3) *XX(2) *XX(1)
  98. 2 2 2 2 2 2
  99. + 12*XX(3) *XX(2) *XX(1) + 12*XX(3) *XX(2) - 12*XX(3) *XX(2)*XX(1)
  100. 2 2 2 2
  101. - 12*XX(3) *XX(2)*XX(1) + 9*XX(3) *XX(1) + 18*XX(3) *XX(1)
  102. 2 3 3
  103. + 9*XX(3) - 2*XX(3)*XX(2) *XX(1) - 2*XX(3)*XX(2)
  104. 2 2 2
  105. + 4*XX(3)*XX(2) *XX(1) + 4*XX(3)*XX(2) *XX(1)
  106. 3 2
  107. - 2*XX(3)*XX(2)*XX(1) - 8*XX(3)*XX(2)*XX(1) - 12*XX(3)*XX(2)*XX(1)
  108. 3 2
  109. - 6*XX(3)*XX(2) + 6*XX(3)*XX(1) + 12*XX(3)*XX(1) + 6*XX(3)*XX(1)
  110. 2 2 2 2 3
  111. + XX(2) *XX(1) + 2*XX(2) *XX(1) + XX(2) - 2*XX(2)*XX(1)
  112. 2 4 3 2
  113. - 4*XX(2)*XX(1) - 2*XX(2)*XX(1) + XX(1) + 2*XX(1) + XX(1)
  114. % Case 5.
  115. let d = (for i := 1:n product (xx(i)+1)) - 3;
  116. for n := 2:5 do write gcd(d*for i := 1:n product (xx(i) - 2),
  117. d*for i := 1:n product (xx(i) + 2));
  118. XX(2)*XX(1) + XX(2) + XX(1) - 2
  119. XX(3)*XX(2)*XX(1) + XX(3)*XX(2) + XX(3)*XX(1) + XX(3) + XX(2)*XX(1)
  120. + XX(2) + XX(1) - 2
  121. XX(4)*XX(3)*XX(2)*XX(1) + XX(4)*XX(3)*XX(2) + XX(4)*XX(3)*XX(1)
  122. + XX(4)*XX(3) + XX(4)*XX(2)*XX(1) + XX(4)*XX(2) + XX(4)*XX(1)
  123. + XX(4) + XX(3)*XX(2)*XX(1) + XX(3)*XX(2) + XX(3)*XX(1) + XX(3)
  124. + XX(2)*XX(1) + XX(2) + XX(1) - 2
  125. XX(5)*XX(4)*XX(3)*XX(2)*XX(1) + XX(5)*XX(4)*XX(3)*XX(2)
  126. + XX(5)*XX(4)*XX(3)*XX(1) + XX(5)*XX(4)*XX(3)
  127. + XX(5)*XX(4)*XX(2)*XX(1) + XX(5)*XX(4)*XX(2) + XX(5)*XX(4)*XX(1)
  128. + XX(5)*XX(4) + XX(5)*XX(3)*XX(2)*XX(1) + XX(5)*XX(3)*XX(2)
  129. + XX(5)*XX(3)*XX(1) + XX(5)*XX(3) + XX(5)*XX(2)*XX(1) + XX(5)*XX(2)
  130. + XX(5)*XX(1) + XX(5) + XX(4)*XX(3)*XX(2)*XX(1) + XX(4)*XX(3)*XX(2)
  131. + XX(4)*XX(3)*XX(1) + XX(4)*XX(3) + XX(4)*XX(2)*XX(1) + XX(4)*XX(2)
  132. + XX(4)*XX(1) + XX(4) + XX(3)*XX(2)*XX(1) + XX(3)*XX(2)
  133. + XX(3)*XX(1) + XX(3) + XX(2)*XX(1) + XX(2) + XX(1) - 2
  134. clear d,u,v;
  135. % The following examples were discussed in Char, B.W., Geddes, K.O.,
  136. % Gonnet, G.H., "GCDHEU: Heuristic Polynomial GCD Algorithm Based
  137. % on Integer GCD Computation", Proc. EUROSAM 84, 285-296, published as
  138. % Lecture Notes on Comp. Science, # 174, Springer-Verlag, Berlin, 1984.
  139. % Maple Problem 1.
  140. gcd(34*x**80-91*x**99+70*x**31-25*x**52+20*x**76-86*x**44-17*x**33
  141. -6*x**89-56*x**54-17,
  142. 91*x**49+64*x**10-21*x**52-88*x**74-38*x**76-46*x**84-16*x**95
  143. -81*x**72+96*x**25-20);
  144. 1
  145. % Maple Problem 2.
  146. g := 34*x**19-91*x+70*x**7-25*x**16+20*x**3-86;
  147. 19 16 7 3
  148. G := 34*X - 25*X + 70*X + 20*X - 91*X - 86
  149. gcd(g * (64*x**34-21*x**47-126*x**8-46*x**5-16*x**60-81),
  150. g * (72*x**60-25*x**25-19*x**23-22*x**39-83*x**52+54*x**10+81) );
  151. 19 16 7 3
  152. 34*X - 25*X + 70*X + 20*X - 91*X - 86
  153. % Maple Problem 3.
  154. gcd(3427088418+8032938293*x-9181159474*x**2-9955210536*x**3
  155. +7049846077*x**4-3120124818*x**5-2517523455*x**6+5255435973*x**7
  156. +2020369281*x**8-7604863368*x**9-8685841867*x**10+4432745169*x**11
  157. -1746773680*x**12-3351440965*x**13-580100705*x**14+8923168914*x**15
  158. -5660404998*x**16 +5441358149*x**17-1741572352*x**18
  159. +9148191435*x**19-4940173788*x**20+6420433154*x**21+980100567*x**22
  160. -2128455689*x**23+5266911072*x**24-8800333073*x**25-7425750422*x**26
  161. -3801290114*x**27-7680051202*x**28-4652194273*x**29-8472655390*x**30
  162. -1656540766*x**31+9577718075*x**32-8137446394*x**33+7232922578*x**34
  163. +9601468396*x**35-2497427781*x**36-2047603127*x**37-1893414455*x**38
  164. -2508354375*x**39-2231932228*x**40,
  165. 2503247071-8324774912*x+6797341645*x**2+5418887080*x**3
  166. -6779305784*x**4+8113537696*x**5+2229288956*x**6+2732713505*x**7
  167. +9659962054*x**8-1514449131*x**9+7981583323*x**10+3729868918*x**11
  168. -2849544385*x**12-5246360984*x**13+2570821160*x**14-5533328063*x**15
  169. -274185102*x**16+8312755945*x**17-2941669352*x**18-4320254985*x**19
  170. +9331460166*x**20-2906491973*x**21-7780292310*x**22-4971715970*x**23
  171. -6474871482*x**24-6832431522*x**25-5016229128*x**26-6422216875*x**27
  172. -471583252*x**28+3073673916*x**29+2297139923*x**30+9034797416*x**31
  173. +6247010865*x**32+5965858387*x**33-4612062748*x**34+5837579849*x**35
  174. -2820832810*x**36-7450648226*x**37+2849150856*x**38+2109912954*x**39
  175. +2914906138*x**40);
  176. 1
  177. % Maple Problem 4.
  178. g := 34271+80330*x-91812*x**2-99553*x**3+70499*x**4-31201*x**5
  179. -25175*x**6+52555*x**7+20204*x**8-76049*x**9-86859*x**10;
  180. 10 9 8 7 6
  181. G := - 86859*X - 76049*X + 20204*X + 52555*X - 25175*X
  182. 5 4 3 2
  183. - 31201*X + 70499*X - 99553*X - 91812*X + 80330*X + 34271
  184. gcd(g * (44328-17468*x-33515*x**2-5801*x**3+89232*x**4-56604*x**5
  185. +54414*x**6-17416*x**7+91482*x**8-49402*x**9+64205*x**10
  186. +9801*x**11-21285*x**12+52669*x**13-88004*x**14-74258*x**15
  187. -38013*x**16-76801*x**17-46522*x**18-84727*x**19-16565*x**20
  188. +95778*x**21-81375*x**22+72330*x**23+96015*x**24-24974*x**25
  189. -20476*x**26-18934*x**27-25084*x**28-22319*x**29+25033*x**30),
  190. g * (-83248+67974*x+54189*x**2-67793*x**3+81136*x**4+22293*x**5
  191. +27327*x**6+96600*x**7-15145*x**8+79816*x**9+37299*x**10
  192. -28496*x**11-52464*x**12+25708*x**13-55334*x**14-2742*x**15
  193. +83128*x**16-29417*x**17-43203*x**18+93315*x**19-29065*x**20
  194. -77803*x**21-49717*x**22-64749*x**23-68325*x**24-50163*x**25
  195. -64222*x**26-4716*x**27+30737*x**28+22972*x**29+90348*x**30));
  196. 10 9 8 7 6 5
  197. 86859*X + 76049*X - 20204*X - 52555*X + 25175*X + 31201*X
  198. 4 3 2
  199. - 70499*X + 99553*X + 91812*X - 80330*X - 34271
  200. % Maple Problem 5.
  201. gcd(-8472*x**4*y**10-8137*x**9*y**10-2497*x**4*y**4-2508*x**4*y**6
  202. -8324*x**9*y**8-6779*x**9*y**6+2733*x**10*y**4+7981*x**7*y**3
  203. -5246*x**6*y**2-274*x**10*y**3-4320,
  204. 15168*x**3*y-4971*x*y-2283*x*y**5+3074*x**6*y**10+6247*x**8*y**2
  205. +2849*x**6*y**7-2039*x**7-2626*x**2*y**7+9229*x**6*y**5+2404*y**5
  206. +1387*x**4*y**8+5602*x**5*y**2-6212*x**3*y**7-8561);
  207. 1
  208. % Maple Problem 6.
  209. g := -19*x**4*y**4+25*y**9+54*x*y**9+22*x**7*y**10-15*x**9*y**7-28;
  210. 9 7 7 10 4 4 9 9
  211. G := - 15*X *Y + 22*X *Y - 19*X *Y + 54*X*Y + 25*Y - 28
  212. gcd(g*(91*x**2*y**9+10*x**4*y**8-88*x*y**3-76*x**2-16*x**10*y
  213. +72*x**10*y**4-20),
  214. g*(34*x**9-99*x**9*y**3-25*x**8*y**6-76*y**7-17*x**3*y**5
  215. +89*x**2*y**8-17));
  216. 9 7 7 10 4 4 9 9
  217. 15*X *Y - 22*X *Y + 19*X *Y - 54*X*Y - 25*Y + 28
  218. % Maple Problem 7.
  219. gcd(6713544209*x**9+8524923038*x**3*y**3*z**7+6010184640*x*z**7
  220. +4126613160*x**3*y**4*z**9+2169797500*x**7*y**4*z**9
  221. +2529913106*x**8*y**5*z**3+7633455535*y*z**3+1159974399*x**2*z**4
  222. +9788859037*y**8*z**9+3751286109*x**3*y**4*z**3,
  223. 3884033886*x**6*z**8+7709443539*x*y**9*z**6
  224. +6366356752*x**9*y**4*z**8+6864934459*x**3*y**2*z**6
  225. +2233335968*x**4*y**9*z**3+2839872507*x**9*y**3*z
  226. +2514142015*x*y*z**2+1788891562*x**4*y**6*z**6
  227. +9517398707*x**8*y**7*z**2+7918789924*x**3*y*z**6
  228. +6054956477*x**6*y**3*z**6);
  229. 1
  230. % Maple Problem 8.
  231. g := u**3*(x**2-y)*z**2+(u-3*u**2*x)*y*z-u**4*x*y+3;
  232. 4 3 2 2 3 2 2
  233. G := - U *X*Y + U *X *Z - U *Y*Z - 3*U *X*Y*Z + U*Y*Z + 3
  234. gcd(g * ((y**2+x)*z**2+u**5*(x*y+x**2)*z-y+5),
  235. g * ((y**2-x)*z**2+u**5*(x*y-x**2)*z+y+9) );
  236. 4 3 2 2 3 2 2
  237. U *X*Y - U *X *Z + U *Y*Z + 3*U *X*Y*Z - U*Y*Z - 3
  238. % Maple Problem 9.
  239. g := 34*u**2*y**2*z-25*u**2*v*z**2-18*v*x**2*z**2-18*u**2*x**2*y*z+53
  240. +x**3;
  241. 2 2 2 2 2 2 2 2 3
  242. G := - 25*U *V*Z - 18*U *X *Y*Z + 34*U *Y *Z - 18*V*X *Z + X + 53
  243. gcd( g * (-85*u*v**2*y**2*z**2-25*u*v*x*y*z-84*u**2*v**2*y**2*z
  244. +27*u**2*v*x**2*y**2*z-53*u*x*y**2*z+34*x**3),
  245. g * (48*x**3-99*u*x**2*y**2*z-69*x*y*z-75*u*v*x*y*z**2
  246. -43*u**2*v+91*u**2*v**2*y**2*z) );
  247. 2 2 2 2 2 2 2 2 3
  248. 25*U *V*Z + 18*U *X *Y*Z - 34*U *Y *Z + 18*V*X *Z - X - 53
  249. % Maple Problem 10.
  250. gcd(-9955*v**9*x**3*y**4*z**8+2020*v*y**7*z**4
  251. -3351*v**5*x**10*y**2*z**8-1741*v**10*x**2*y**9*z**6
  252. -2128*v**8*y*z**3-7680*v**2*y**4*z**10-8137*v**9*x**10*y**4*z**4
  253. -1893*v**4*x**4*y**6+6797*v**8*x*y**9*z**6
  254. +2733*v**10*x**4*y**9*z**7-2849*v**2*x**6*y**2*z**5
  255. +8312*v**3*x**3*y**10*z**3-7780*v**2*x*y*z**2
  256. -6422*v**5*x**7*y**6*z**10+6247*v**8*x**2*y**8*z**3
  257. -7450*v**7*x**6*y**7*z**4+3625*x**4*y**2*z**7+9229*v**6*x**5*y**6
  258. -112*v**6*x**4*y**8*z**7-7867*v**5*x**8*y**5*z**2
  259. -6212*v**3*x**7*z**5+8699*v**8*x**2*y**2*z**5
  260. +4442*v**10*x**5*y**4*z+1965*v**10*y**3*z**3-8906*v**6*x*y**4*z**5
  261. +5552*x**10*y**4+3055*v**5*x**3*y**6*z**2+6658*v**7*x**10*z**6
  262. +3721*v**8*x**9*y**4*z**8+9511*v*x**6*y+5437*v**3*x**9*y**9*z**7
  263. -1957*v**6*x**4*y*z**3+9214*v**3*x**9*y**3*z**7
  264. +7273*v**2*x**8*y**4*z**10+1701*x**10*y**7*z**2
  265. +4944*v**5*x**5*y**8*z**8-1935*v**3*x**6*y**10*z**7
  266. +4029*x**6*y**10*z**3+9462*v**6*x**5*y**4*z**8-3633*v**4*x*y**7*z**5
  267. -1876,
  268. -5830*v**7*x**8*y*z**2-1217*v**8*x*y**2*z**5
  269. -1510*v**9*x**3*y**10*z**10+7036*v**6*x**8*y**3*z**3
  270. +1022*v**9*y**3*z**8+3791*v**8*x**3*y**7+6906*v**6*x*y*z**10
  271. +117*v**7*x**2*y**4*z**4+6654*v**6*x**5*y**2*z**3
  272. -7302*v**10*x**8*y**3-5343*v**8*x**5*y**9*z
  273. -2244*v**9*x**3*y**8*z**9-3719*v**5*x**10*y**6*z**8
  274. +2629*x**3*y**2*z**10+8517*x**9*y**6*z**7-9551*v**5*x**6*y**6*z**2
  275. -7750*x**10*y**7*z**4-5035*v**5*x**2*y**5*z-5967*v**9*x**5*y**9*z**5
  276. -8517*v**3*x**2*y**7*z**6-2668*v**10*y**9*z**4+1630*v**5*x**5*y*z**8
  277. +9099*v**7*x**9*y**4*z**3-5358*v**9*x**5*y**6*z**2
  278. +5766*v**5*y**3*z**4-3624*v*x**4*y**10*z**10
  279. +8839*v**6*x**9*y**10*z**4+3378*x**7*y**2*z**5+7582*v**7*x*y**8*z**7
  280. -85*v*x**2*y**9*z**6-9495*v**9*x**10*y**6*z**3+1983*v**9*x**3*y
  281. -4613*v**10*x**4*y**7*z**6+5529*v**10*x*y**6
  282. +5030*v**4*x**5*y**4*z**9-9202*x**6*y**3*z**9
  283. -4988*v**2*x**2*y**10*z**4-8572*v**9*x**7*y**10*z**10
  284. +4080*v**4*x**8*z**8-382*v**9*x**9*y**2*z**2-7326);
  285. 1
  286. end;
  287. 4: 4:
  288. Quitting
  289. Sat Jun 29 13:41:02 PDT 1991