arnum.rlg 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. Sun Aug 18 16:14:07 2002 run on Windows
  2. % Test of algebraic number package.
  3. defpoly sqrt2**2-2;
  4. 1/(sqrt2+1);
  5. sqrt2 - 1
  6. (x**2+2*sqrt2*x+2)/(x+sqrt2);
  7. x + sqrt2
  8. on gcd;
  9. (x**3+(sqrt2-2)*x**2-(2*sqrt2+3)*x-3*sqrt2)/(x**2-2);
  10. 2
  11. x - 2*x - 3
  12. --------------
  13. x - sqrt2
  14. off gcd;
  15. sqrt(x**2-2*sqrt2*x*y+2*y**2);
  16. x - sqrt2*y
  17. off arnum;
  18. %to start a new algebraic extension.
  19. defpoly cbrt5**3-5;
  20. on rationalize;
  21. 1/(x-cbrt5);
  22. 2 2
  23. x + cbrt5*x + cbrt5
  24. -----------------------
  25. 3
  26. x - 5
  27. off rationalize;
  28. off arnum;
  29. %to start a new algebraic extension.
  30. %The following examples are taken from P.S. Wang Math. Comp. 30,
  31. % 134,(1976),p.324.
  32. on factor;
  33. defpoly i**2+1=0;
  34. w0 := x**2+1;
  35. w0 := (x + i)*(x - i)
  36. w1 := x**4-1;
  37. w1 := (x + i)*(x - i)*(x + 1)*(x - 1)
  38. w2 := x**4+(i+2)*x**3+(2*i+5)*x**2+(2*i+6)*x+6;
  39. 2
  40. w2 := (x + i*x + 3)*(x + i + 1)*(x - (i - 1))
  41. w3 := (2*i+3)*x**4+(3*i-2)*x**3-2*(i+1)*x**2+i*x-1;
  42. 2 2 2 3
  43. w3 := (2*i + 3)*(x + i*x - 1)*(x - (----*i - ----))
  44. 13 13
  45. off arnum;
  46. defpoly a**2-5;
  47. w4 := x**2+x-1;
  48. 1 1 1 1
  49. w4 := (x + ---*a + ---)*(x - (---*a - ---))
  50. 2 2 2 2
  51. off arnum;
  52. defpoly a**2+a+2;
  53. w5 := x**4+3*x**2+4;
  54. w5 := (x + a + 1)*(x + a)*(x - (a + 1))*(x - a)
  55. off arnum;
  56. defpoly a**3+2=0;
  57. w6:=64*x**6-4;
  58. 2 1 1 2 2 1 1 2 1 1
  59. w6 := 64*(x + ---*a*x + ---*a )*(x - ---*a*x + ---*a )*(x + ---*a)*(x - ---*a)
  60. 2 4 2 4 2 2
  61. off arnum;
  62. defpoly a**4+a**3+a**2+a+1=0;
  63. w7:=16*x**4+8*x**3+4*x**2+2*x+1;
  64. w7 :=
  65. 1 3 1 2 1 1 1 3 1 2 1
  66. 16*(x + ---*a + ---*a + ---*a + ---)*(x - ---*a )*(x - ---*a )*(x - ---*a)
  67. 2 2 2 2 2 2 2
  68. off arnum, factor;
  69. defpoly sqrt5**2-5,cbrt3**3-3;
  70. *** Defining polynomial for primitive element:
  71. 6 4 3 2
  72. a1 - 15*a1 - 6*a1 + 75*a1 - 90*a1 - 116
  73. cbrt3**3;
  74. 3
  75. sqrt5**2;
  76. 5
  77. cbrt3;
  78. 120 5 27 4 2000 3 1170 2 6676 6825
  79. - (------*a1 + ------*a1 - ------*a1 - ------*a1 + ------*a1 - ------)
  80. 8243 8243 8243 8243 8243 8243
  81. sqrt5;
  82. 120 5 27 4 2000 3 1170 2 14919 6825
  83. ------*a1 + ------*a1 - ------*a1 - ------*a1 + -------*a1 - ------
  84. 8243 8243 8243 8243 8243 8243
  85. sqrt(x**2+2*(sqrt5-cbrt3)*x+5-2*sqrt5*cbrt3+cbrt3**2);
  86. 240 5 54 4 4000 3 2340 2 21595 13650
  87. x + ------*a1 + ------*a1 - ------*a1 - ------*a1 + -------*a1 - -------
  88. 8243 8243 8243 8243 8243 8243
  89. on rationalize;
  90. 1/(x+sqrt5-cbrt3);
  91. 5 240 5 54 4 4000 3 2340 2 21595 13650
  92. (x - (------*a1 + ------*a1 - ------*a1 - ------*a1 + -------*a1 - -------)
  93. 8243 8243 8243 8243 8243 8243
  94. 4
  95. *x -
  96. 108 5 800 4 1800 3 15433 2 15900 14465 3
  97. (------*a1 - ------*a1 - ------*a1 + -------*a1 + -------*a1 + -------)*x
  98. 8243 8243 8243 8243 8243 8243
  99. 3 2
  100. - (a1 - 15*a1)*x -
  101. 900 5 3919 4 15000 3 8775 2 148986 154225
  102. (------*a1 - ------*a1 - -------*a1 - ------*a1 + --------*a1 - --------)*x
  103. 8243 8243 8243 8243 8243 8243
  104. 1919 5 1050 4 18245 3 12528 2 236725 73080
  105. - (------*a1 + ------*a1 - -------*a1 - -------*a1 + --------*a1 - -------
  106. 8243 8243 8243 8243 8243 8243
  107. 6 4 3 2
  108. ))/(x - 15*x - 6*x + 75*x - 90*x - 116)
  109. off arnum, rationalize;
  110. split_field(x**3+2);
  111. *** Splitting field is generated by:
  112. 6
  113. a3 + 108
  114. 1 4 1
  115. {----*a3 + ---*a3,
  116. 36 2
  117. 1 4
  118. - ----*a3 ,
  119. 18
  120. 1 4 1
  121. ----*a3 - ---*a3}
  122. 36 2
  123. for each j in ws product (x-j);
  124. 3
  125. x + 2
  126. split_field(x**3+4*x**2+x-1);
  127. *** Splitting field is generated by:
  128. 3 2
  129. a4 + 4*a4 + a4 - 1
  130. 2 2
  131. {a4,a4 + 3*a4 - 2, - (a4 + 4*a4 + 2)}
  132. for each j in ws product (x-j);
  133. 3 2
  134. x + 4*x + x - 1
  135. split_field(x**3-3*x+7);
  136. *** Splitting field is generated by:
  137. 6 4 2
  138. a6 - 18*a6 + 81*a6 + 1215
  139. 1 4 5 2 1 2
  140. {-----*a6 - ----*a6 + ---*a6 + ---,
  141. 126 42 2 7
  142. 1 4 5 2 4
  143. - (----*a6 - ----*a6 + ---),
  144. 63 21 7
  145. 1 4 5 2 1 2
  146. -----*a6 - ----*a6 - ---*a6 + ---}
  147. 126 42 2 7
  148. for each j in ws product (x-j);
  149. 3
  150. x - 3*x + 7
  151. split_field(x**3+4*x**2+x-1);
  152. *** Splitting field is generated by:
  153. 3 2
  154. a7 + 4*a7 + a7 - 1
  155. 2 2
  156. {a7,a7 + 3*a7 - 2, - (a7 + 4*a7 + 2)}
  157. for each j in ws product (x-j);
  158. 3 2
  159. x + 4*x + x - 1
  160. split_field(x**3-x**2-x-1);
  161. *** Splitting field is generated by:
  162. 6 5 4 3 2
  163. a9 - 6*a9 + 7*a9 + 12*a9 - 17*a9 - 6*a9 + 53
  164. 3 4 3 3 1 2 5 17
  165. { - (----*a9 - ----*a9 - ----*a9 - ----*a9 + ----),
  166. 76 19 38 38 76
  167. 3 4 6 3 1 2 14 17
  168. ----*a9 - ----*a9 - ----*a9 + ----*a9 + ----,
  169. 38 19 19 19 38
  170. 3 4 3 3 1 2 33 59
  171. - (----*a9 - ----*a9 - ----*a9 + ----*a9 - ----)}
  172. 76 19 38 38 76
  173. for each j in ws product (x-j);
  174. 3 2
  175. x - x - x - 1
  176. % A longer example.
  177. off arnum;
  178. defpoly a**6+3*a**5+6*a**4+a**3-3*a**2+12*a+16;
  179. factorize(x**3-3);
  180. 1 5 1 4 2 3 1 2 2 7
  181. {{x + ---*a + ---*a + ---*a - ---*a + ---*a + ---,1},
  182. 6 3 3 6 3 3
  183. 1 5 1 4 1 3 7 2 11 4
  184. {x - (----*a + ----*a + ---*a - ----*a + ----*a + ---),1},
  185. 12 12 6 12 12 3
  186. 1 5 1 4 1 3 5 2 1
  187. {x - (----*a + ---*a + ---*a + ----*a - ---*a + 1),1}}
  188. 12 4 2 12 4
  189. end;
  190. Time for test: 2955 ms, plus GC time: 140 ms