DECOMPOS.LOG 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. REDUCE 3.6, 15-Jul-95, patched to 6 Mar 96 ...
  2. % Test for the univariate and multivariate polynomial decomposition.
  3. % Herbert Melenk, ZIB Berlin, 1990.
  4. procedure testdecompose u;
  5. begin scalar r,p,val,nextvar;
  6. write "decomposition of ",u;
  7. r := decompose u;
  8. if length r = 1 then rederr "decomposition failed";
  9. write " leads to ",r;
  10. % test if the result is algebraically correct.
  11. r := reverse r;
  12. nextvar := lhs first r; val := rhs first r;
  13. r := rest r;
  14. while not(r={}) do
  15. << p := first r; r := rest r;
  16. if 'equal = part(p,0) then
  17. <<val := sub(nextvar=val,rhs p); nextvar := lhs p>>
  18. else
  19. val := sub(nextvar=val,p);
  20. >>;
  21. if val = u then write " O.K. "
  22. else
  23. <<write "**** reconstructed polynomial: ";
  24. write val;
  25. rederr "reconstruction leads to different polynomial";
  26. >>;
  27. end;
  28. testdecompose
  29. % univariate decompositions
  30. testdecompose(x**4+x**2+1);
  31. 4 2
  32. decomposition of x + x + 1
  33. 2 2
  34. leads to {u + u + 1,u=x }
  35. O.K.
  36. testdecompose(x**6+9x**5+52x**4+177x**3+435x**2+630x+593);
  37. 6 5 4 3 2
  38. decomposition of x + 9*x + 52*x + 177*x + 435*x + 630*x + 593
  39. 3 2 2
  40. leads to {u + 25*u + 210*u + 593,u=x + 3*x}
  41. O.K.
  42. testdecompose(x**6+6x**4+x**3+9x**2+3x-5);
  43. 6 4 3 2
  44. decomposition of x + 6*x + x + 9*x + 3*x - 5
  45. 2 3
  46. leads to {u + u - 5,u=x + 3*x}
  47. O.K.
  48. testdecompose(x**8-88*x**7+2924*x**6-43912*x**5+263431*x**4-218900*x**3+
  49. 65690*x**2-7700*x+234);
  50. 8 7 6 5 4 3
  51. decomposition of x - 88*x + 2924*x - 43912*x + 263431*x - 218900*x
  52. 2
  53. + 65690*x - 7700*x + 234
  54. 2
  55. leads to {u + 35*u + 234,
  56. 2
  57. u=v + 10*v,
  58. 2
  59. v=x - 22*x}
  60. O.K.
  61. % multivariate cases
  62. testdecompose(u**2+v**2+2u*v+1);
  63. 2 2
  64. decomposition of u + 2*u*v + v + 1
  65. 2
  66. leads to {w + 1,w=u + v}
  67. O.K.
  68. testdecompose(x**4+2x**3*y + 3x**2*y**2 + 2x*y**3 + y**4 + 2x**2*y
  69. +2x*y**2 + 2y**3 + 5 x**2 + 5*x*y + 6*y**2 + 5y + 9);
  70. 4 3 2 2 2 2 3 2
  71. decomposition of x + 2*x *y + 3*x *y + 2*x *y + 5*x + 2*x*y + 2*x*y + 5*x*y
  72. 4 3 2
  73. + y + 2*y + 6*y + 5*y + 9
  74. 2 2 2
  75. leads to {u + 5*u + 9,u=x + x*y + y + y}
  76. O.K.
  77. testdecompose sub(u=(2 x**2 + 17 x+y + y**3),u**2+2 u + 1);
  78. 4 3 2 3 2 2 3
  79. decomposition of 4*x + 68*x + 4*x *y + 4*x *y + 293*x + 34*x*y + 34*x*y
  80. 6 4 3 2
  81. + 34*x + y + 2*y + 2*y + y + 2*y + 1
  82. 2 2 3
  83. leads to {u + 2*u + 1,u=2*x + 17*x + y + y}
  84. O.K.
  85. testdecompose sub(u=(2 x**2 *y + 17 x+y + y**3),u**2+2 u + 1);
  86. 4 2 3 2 4 2 2 2 2
  87. decomposition of 4*x *y + 68*x *y + 4*x *y + 4*x *y + 4*x *y + 289*x
  88. 3 6 4 3 2
  89. + 34*x*y + 34*x*y + 34*x + y + 2*y + 2*y + y + 2*y + 1
  90. 2 2 3
  91. leads to {u + 2*u + 1,u=2*x *y + 17*x + y + y}
  92. O.K.
  93. % some cases which require a special (internal) mapping
  94. testdecompose ( (x + y)**2);
  95. 2 2
  96. decomposition of x + 2*x*y + y
  97. 2
  98. leads to {u ,u=x + y}
  99. O.K.
  100. testdecompose ((x + y**2)**2);
  101. 2 2 4
  102. decomposition of x + 2*x*y + y
  103. 2 2
  104. leads to {u ,u=x + y }
  105. O.K.
  106. testdecompose ( (x**2 + y)**2);
  107. 4 2 2
  108. decomposition of x + 2*x *y + y
  109. 2 2
  110. leads to {u ,u=x + y}
  111. O.K.
  112. testdecompose ( (u + v)**2 +10 );
  113. 2 2
  114. decomposition of u + 2*u*v + v + 10
  115. 2
  116. leads to {w + 10,w=u + v}
  117. O.K.
  118. % the decomposition is not unique and might generate quite
  119. % different images:
  120. testdecompose ( (u + v + 10)**2 -100 );
  121. 2 2
  122. decomposition of u + 2*u*v + 20*u + v + 20*v
  123. leads to {w*(w + 20),w=u + v}
  124. O.K.
  125. % some special (difficult) cases
  126. testdecompose (X**4 + 88*X**3*Y + 2904*X**2*Y**2 - 10*X**2
  127. + 42592*X*Y**3 - 440*X*Y + 234256*Y**4 - 4840*Y**2);
  128. 4 3 2 2 2 3
  129. decomposition of x + 88*x *y + 2904*x *y - 10*x + 42592*x*y - 440*x*y
  130. 4 2
  131. + 234256*y - 4840*y
  132. 2
  133. leads to {u*(u - 10),u=v ,v=x + 22*y}
  134. O.K.
  135. % a polynomial with complex coefficients
  136. on complex;
  137. testdecompose(X**4 + (88*I)*X**3*Y - 2904*X**2*Y**2 - 10*X**2 -
  138. (42592*I)*X*Y**3 - (440*I)*X*Y + 234256*Y**4 + 4840*Y**2);
  139. 4 3 2 2 2 3
  140. decomposition of x + 88*i*x *y - 2904*x *y - 10*x - 42592*i*x*y - 440*i*x*y
  141. 4 2
  142. + 234256*y + 4840*y
  143. 2
  144. leads to {u*(u - 10),u=v ,v=x + 22*i*y}
  145. O.K.
  146. off complex;
  147. % Examples given by J. Gutierrez and J.M. Olazabal.
  148. f1:=x**6-2x**5+x**4-3x**3+3x**2+5$
  149. testdecompose(f1);
  150. 6 5 4 3 2
  151. decomposition of x - 2*x + x - 3*x + 3*x + 5
  152. 2 3 2
  153. leads to {u - 3*u + 5,u=x - x }
  154. O.K.
  155. f2:=x**32-1$
  156. testdecompose(f2);
  157. 32
  158. decomposition of x - 1
  159. 2 2 2 2 2
  160. leads to {u - 1,u=v ,v=w ,w=a ,a=x }
  161. O.K.
  162. f3:=x**4-(2/3)*x**3-(26/9)*x**2+x+3$
  163. testdecompose(f3);
  164. 4 3 2
  165. 9*x - 6*x - 26*x + 9*x + 27
  166. decomposition of --------------------------------
  167. 9
  168. 2
  169. u - 9*u + 27 2
  170. leads to {---------------,u=3*x - x}
  171. 9
  172. O.K.
  173. f4:=sub(x=x**4-x**3-2x+1,x**3-x**2-1)$
  174. testdecompose(f4);
  175. 12 11 10 9 8 7 6 5
  176. decomposition of x - 3*x + 3*x - 7*x + 14*x - 10*x + 14*x - 20*x
  177. 4 3 2
  178. + 9*x - 9*x + 8*x - 2*x - 1
  179. 3 2 4 3
  180. leads to {u + 2*u + u - 1,u=x - x - 2*x}
  181. O.K.
  182. f5:=sub(x=f4,x**5-5)$
  183. testdecompose(f5);
  184. 60 59 58 57 56 55
  185. decomposition of x - 15*x + 105*x - 485*x + 1795*x - 5873*x
  186. 54 53 52 51 50
  187. + 17255*x - 45845*x + 112950*x - 261300*x + 567203*x
  188. 49 48 47 46
  189. - 1164475*x + 2280835*x - 4259830*x + 7604415*x
  190. 45 44 43 42
  191. - 13053437*x + 21545220*x - 34200855*x + 52436150*x
  192. 41 40 39 38
  193. - 77668230*x + 111050794*x - 153746645*x + 206190770*x
  194. 37 36 35
  195. - 267484170*x + 336413145*x - 410387890*x
  196. 34 33 32
  197. + 484672110*x - 555048350*x + 616671710*x
  198. 31 30 29
  199. - 663135380*x + 690884384*x - 697721320*x
  200. 28 27 26
  201. + 681039235*x - 642661265*x + 586604975*x
  202. 25 24 23
  203. - 516016275*x + 437051535*x - 356628245*x
  204. 22 21 20
  205. + 278991765*x - 208571965*x + 149093999*x
  206. 19 18 17 16
  207. - 101204325*x + 64656350*x - 38848040*x + 21710870*x
  208. 15 14 13 12
  209. - 10971599*x + 4928210*x - 1904450*x + 519730*x
  210. 11 10 9 8 7
  211. - 15845*x - 71947*x + 52015*x - 26740*x + 5510*x
  212. 6 5 4 3
  213. + 3380*x - 1972*x - 75*x + 195*x - 10*x - 6
  214. 5 4 3 2
  215. leads to {u - 5*u + 10*u - 10*u + 5*u - 6,
  216. 3 2
  217. u=v + 2*v + v,
  218. 4 3
  219. v=x - x - 2*x}
  220. O.K.
  221. clear f1,f2,f3,f4,f5;
  222. end;
  223. (TIME: decompos 2550 2810)