wu.rlg 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. Tue Feb 10 12:29:48 2004 run on Linux
  2. % wu.tst
  3. % Russell Bradford, 8 June 90.
  4. % Some tests for the Wu algorithm
  5. % The order directives are not necessary for general use: they just
  6. % help tie things down for testing purposes.
  7. % run after loading Wu code: in "wu.red"$
  8. % test 1
  9. order x,y,a,b;
  10. wu({x^2+y^2-a,x*y-b}, {x,y});
  11. 4 2 2
  12. {{{ - y + y *a - b , - x*y + b},
  13. y}}
  14. % test 2
  15. order x,y,a,b;
  16. wu({x^2+y^2-a,x*y-b},{x,y,a,b});
  17. 2
  18. {{{b,y, - x + a},1},
  19. 4 2 2
  20. {{ - y + y *a - b , - x*y + b},
  21. y}}
  22. % test 3
  23. order x,y,z,r;
  24. wu({x^2+y^2+z^2-r^2, x*y+z^2-1, x*y*z-x^2-y^2-z+1}, {x,y,z});
  25. 3 2 2
  26. {{{z - z + r - 1,
  27. 4 2 2 2 2 2 2 2
  28. - y - y *z + y *r + z + z*r - z + r - 2,
  29. 2
  30. x*y + z - 1},
  31. y},
  32. 7 6 5 4 2 4 3 2 2 2 2
  33. {{z - z - 2*z + z *r + z + z - 2*z *r + z + r - 1,
  34. 2 3 2 2
  35. y *(z - z + r - 1),
  36. 2
  37. x*y + z - 1},
  38. 3 2 2
  39. y*(z - z + r - 1)}}
  40. % test 4
  41. order x,y,z,r;
  42. wu({x^2+y^2+z^2-r^2, x*y+z^2-1, x*y*z-x^2-y^2-z+1}, {x,y,z,r});
  43. 3 2 2
  44. {{{z - z + r - 1,
  45. 4 2 2 2 2 2 2 2
  46. - y - y *z + y *r + z + z*r - z + r - 2,
  47. 2
  48. x*y + z - 1},
  49. y},
  50. 4 2
  51. {{r - 4*r + 3,
  52. 2
  53. z + r - 2,
  54. y,
  55. 2 2
  56. - x + r - 1},
  57. 1},
  58. 7 6 5 4 2 4 3 2 2 2 2
  59. {{z - z - 2*z + z *r + z + z - 2*z *r + z + r - 1,
  60. 2 3 2 2
  61. y *(z - z + r - 1),
  62. 2
  63. x*y + z - 1},
  64. 3 2 2
  65. y*(z - z + r - 1)}}
  66. % test 5
  67. order x,y,z;
  68. wu({(x-1)*(y-1)*(z-1), (x-2)*(y-2)*(z-2), (x-3)*(y-3)*(z-3)}, {x,y,z});
  69. 2
  70. {{{z - 5*z + 6,
  71. 2 2
  72. 2*(y *z - 3*y - 4*y*z + 12*y + 3*z - 9),
  73. x*y*z - 3*x*y - 3*x*z + 9*x - 3*y*z + 9*y + 9*z - 27},
  74. 2 2
  75. 2*(y*z - 6*y*z + 9*y - 3*z + 18*z - 27)},
  76. {{z - 3,y - 2,2*(x - 1)},2},
  77. 2
  78. {{z - 3,2*(y - 3*y + 2),x*y - 2*x - 2*y + 4},
  79. 2*(y - 2)},
  80. {{2*(z - 3),2*(y - 2),4*(x - 1)},16},
  81. 2
  82. {{2*(z - 3),4*(y - 3*y + 2),2*(x*y - 2*x - 2*y + 4)},
  83. 16*(y - 2)},
  84. 2
  85. {{z - 5*z + 6,
  86. y*z - 3*y - 3*z + 9,
  87. 2*(x*z - 3*x - z + 3)},
  88. 2
  89. 2*(z - 6*z + 9)},
  90. 3 2
  91. {{2*(z - 6*z + 11*z - 6),
  92. y*z - 3*y - 3*z + 9,
  93. 2 2
  94. x*z - 5*x*z + 6*x - 2*z + 10*z - 12},
  95. 3 2
  96. 2*(z - 8*z + 21*z - 18)},
  97. 3 2
  98. {{4*(z - 6*z + 11*z - 6),
  99. 2 2 2 2 2 2
  100. y *z - 5*y *z + 6*y - 5*y*z + 25*y*z - 30*y + 6*z - 30*z + 36,
  101. x*y*z - 3*x*y - 3*x*z + 9*x - 3*y*z + 9*y + 9*z - 27},
  102. 3 2 3 2
  103. 4*(y*z - 8*y*z + 21*y*z - 18*y - 3*z + 24*z - 63*z + 54)}}
  104. % test 6
  105. order x,y,z;
  106. wu({(x-1)*(y-1)*(z-1), (x-2)*(y-2)*(z-2), (x-3)*(y-3)*(z-3)});
  107. 2
  108. {{{z - 5*z + 6,
  109. 2 2
  110. 2*(y *z - 3*y - 4*y*z + 12*y + 3*z - 9),
  111. x*y*z - 3*x*y - 3*x*z + 9*x - 3*y*z + 9*y + 9*z - 27},
  112. 2 2
  113. 2*(y*z - 6*y*z + 9*y - 3*z + 18*z - 27)},
  114. {{z - 3,y - 2,2*(x - 1)},2},
  115. 2
  116. {{z - 3,2*(y - 3*y + 2),x*y - 2*x - 2*y + 4},
  117. 2*(y - 2)},
  118. {{2*(z - 3),2*(y - 2),4*(x - 1)},16},
  119. 2
  120. {{2*(z - 3),4*(y - 3*y + 2),2*(x*y - 2*x - 2*y + 4)},
  121. 16*(y - 2)},
  122. 2
  123. {{z - 5*z + 6,
  124. y*z - 3*y - 3*z + 9,
  125. 2*(x*z - 3*x - z + 3)},
  126. 2
  127. 2*(z - 6*z + 9)},
  128. 3 2
  129. {{2*(z - 6*z + 11*z - 6),
  130. y*z - 3*y - 3*z + 9,
  131. 2 2
  132. x*z - 5*x*z + 6*x - 2*z + 10*z - 12},
  133. 3 2
  134. 2*(z - 8*z + 21*z - 18)},
  135. 3 2
  136. {{4*(z - 6*z + 11*z - 6),
  137. 2 2 2 2 2 2
  138. y *z - 5*y *z + 6*y - 5*y*z + 25*y*z - 30*y + 6*z - 30*z + 36,
  139. x*y*z - 3*x*y - 3*x*z + 9*x - 3*y*z + 9*y + 9*z - 27},
  140. 3 2 3 2
  141. 4*(y*z - 8*y*z + 21*y*z - 18*y - 3*z + 24*z - 63*z + 54)}}
  142. % test 7
  143. order x1,x2,x3,x4;
  144. p1 := x1+x2+x3+x4;
  145. p1 := x1 + x2 + x3 + x4
  146. p2 := x1*x2+x2*x3+x3*x4+x4*x1;
  147. p2 := x1*x2 + x1*x4 + x2*x3 + x3*x4
  148. p3 := x1*x2*x3+x2*x3*x4+x3*x4*x1+x4*x1*x2;
  149. p3 := x1*x2*x3 + x1*x2*x4 + x1*x3*x4 + x2*x3*x4
  150. p4 := x1*x2*x3*x4 - 1;
  151. p4 := x1*x2*x3*x4 - 1
  152. wu({p1,p2,p3,p4}, {x1,x2,x3,x4});
  153. 4
  154. {{{x4*(x4 - 1),
  155. 2
  156. x4 *(x3 - x4),
  157. 2 2 2
  158. x4 *(x2 + 2*x2*x4 + x4 ),
  159. 2
  160. x4 *(x1 + x2 + 2*x4)},
  161. 6
  162. x4 },
  163. 4
  164. {{x4 - 1,
  165. 2
  166. x4 *(x3 - x4),
  167. 2 2
  168. 2*x4*(x2 + 2*x2*x4 + x4 ),
  169. 2
  170. x4 *(x1 + x2 + 2*x4)},
  171. 5
  172. 2*x4 },
  173. 4
  174. {{x4 - 1,
  175. x3 - x4,
  176. 2 2
  177. x2 + 2*x2*x4 + x4 ,
  178. x1 + x2 + 2*x4},
  179. 1},
  180. 4
  181. {{x4 - 1,
  182. 2 2
  183. x3 - x4 ,
  184. 2 3 3
  185. x2*x3*x4 - x2*x4 + x3*x4 - 1,
  186. 2
  187. x1*x3 - x1*x4 - x3*x4 + x4 },
  188. 2 2 2
  189. x4 *(x3 - 2*x3*x4 + x4 )},
  190. 8 4
  191. {{x4 - 2*x4 + 1,
  192. 2 2
  193. x3 - x4 ,
  194. 2 3 3
  195. x2*x3*x4 - x2*x4 + x3*x4 - 1,
  196. 4 4
  197. x1*x4 - x1 + x3*x4 - x3},
  198. 2 4 5
  199. x4 *(x3*x4 - x3 - x4 + x4)},
  200. 2 4
  201. {{x4 *(x4 - 1),
  202. 3
  203. x4 *(x3 - x4),
  204. 3 2 2
  205. x4 *(x2 + 2*x2*x4 + x4 ),
  206. 3
  207. x4 *(x1 + x2 + 2*x4)},
  208. 9
  209. x4 },
  210. 4
  211. {{x4*(x4 - 1),
  212. 3
  213. x4 *(x3 - x4),
  214. 2 2 2
  215. 2*x4 *(x2 + 2*x2*x4 + x4 ),
  216. 3
  217. x4 *(x1 + x2 + 2*x4)},
  218. 8
  219. 2*x4 },
  220. 4
  221. {{x4 - 1,
  222. x4*(x3 - x4),
  223. 2 2
  224. x4*(x2 + 2*x2*x4 + x4 ),
  225. x4*(x1 + x2 + 2*x4)},
  226. 3
  227. x4 },
  228. 4
  229. {{x4*(x4 - 1),
  230. 2 2 2
  231. x4 *(x3 - x4 ),
  232. 2 3 3
  233. x4*(x2*x3*x4 - x2*x4 + x3*x4 - 1),
  234. 2
  235. x4*(x1*x3 - x1*x4 - x3*x4 + x4 )},
  236. 6 2 2
  237. x4 *(x3 - 2*x3*x4 + x4 )},
  238. 8 4
  239. {{x4*(x4 - 2*x4 + 1),
  240. 2 2 2
  241. x4 *(x3 - x4 ),
  242. 2 3 3
  243. x4*(x2*x3*x4 - x2*x4 + x3*x4 - 1),
  244. 4 4
  245. x4*(x1*x4 - x1 + x3*x4 - x3)},
  246. 6 4 5
  247. x4 *(x3*x4 - x3 - x4 + x4)},
  248. 3 2 2 3
  249. {{x3 *x4 + x3 *x4 - x3 - x4,
  250. 2 2 2 3
  251. x2*x3 - x2*x4 + x3 *x4 - x4 ,
  252. 2 2 4 2 3 4
  253. x1*x3 *x4 - x1*x4 - x3 *x4 - x3*x4 + x3 + x4},
  254. 4 4 2 2 4
  255. x4 *(x3 - 2*x3 *x4 + x4 )}}
  256. % test 8
  257. order x,y,z;
  258. wu({z*z,y*z-1,x*z-1}, {x,y,z});
  259. {{{1},1}}
  260. end;
  261. Time for test: 60 ms