groebner.rlg 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. Tue Feb 10 12:28:13 2004 run on Linux
  2. % Examples of use of Groebner code.
  3. % In the Examples 1 - 3 the polynomial ring for the ideal operations
  4. % (variable sequence, term order mode) is defined globally in advance.
  5. % Example 1, Linz 85.
  6. torder ({q1,q2,q3,q4,q5,q6},lex)$
  7. groebner {q1,
  8. q2**2 + q3**2 + q4**2,
  9. q4*q3*q2,
  10. q3**2*q2**2 + q4**2*q2**2 + q4**2*q3**2,
  11. q6**2 + 1/3*q5**2,
  12. q6**3 - q5**2*q6,
  13. 2*q2**2*q6 - q3**2*q6 - q4**2*q6 + q3**2*q5 - q4**2*q5,
  14. 2*q2**2*q6**2 - q3**2*q6**2 - q4**2*q6**2 - 2*q3**2*q5*q6
  15. + 2*q4**2*q5*q6 - 2/3*q2**2*q5**2 + 1/3*q3**2*q5**2
  16. + 1/3*q4**2*q5**2,
  17. - q3**2*q2**2*q6 - q4**2*q2**2*q6 + 2*q4**2*q3**2*q6 -
  18. q3**2*q2**2*q5 + q4**2*q2**2*q5,
  19. - q3**2*q2**2*q6**2 - q4**2*q2**2*q6**2 + 2*q4**2*q3**2*q6**2
  20. + 2*q3**2*q2**2*q5*q6 - 2*q4**2*q2**2*q5*q6 + 1/3*q3**2*q2**2
  21. *q5**2 + 1/3*q4**2*q2**2*q5**2 - 2/3*q4**2*q3**2*q5**2,
  22. - 3*q3**2*q2**4*q5*q6**2 + 3*q4**2*q2**4*q5*q6**2
  23. + 3*q3**4*q2**2*q5*q6**2 - 3*q4**4*q2**2*q5*q6**2
  24. - 3*q4**2*q3**4*q5*q6**2 + 3*q4**4*q3**2*q5*q6**2
  25. + 1/3*q3**2*q2**4*q5**3 - 1/3*q4**2*q2**4*q5**3
  26. - 1/3*q3**4*q2**2*q5**3 + 1/3*q4**4*q2**2*q5**3 + 1/3*q4**2
  27. *q3**4*q5**3 - 1/3*q4**4*q3**2*q5**3};
  28. {q1,
  29. 2 2 2
  30. q2 + q3 + q4 ,
  31. q2*q3*q4,
  32. 4
  33. q2*q4 *q6,
  34. 3 3
  35. q2*q4 *q5 + 3*q2*q4 *q6,
  36. 3 2
  37. q2*q4 *q6 ,
  38. 4 2 2 4
  39. q3 + q3 *q4 + q4 ,
  40. 3 3
  41. q3 *q4 + q3*q4 ,
  42. 2 2
  43. q3 *q4 *q6,
  44. 2 2 2 2
  45. q3 *q5 - 3*q3 *q6 - q4 *q5 - 3*q4 *q6,
  46. 2 2 2 2
  47. q3 *q6 + q4 *q6 ,
  48. 4
  49. q3*q4 *q6,
  50. 3
  51. q3*q4 *q5,
  52. 3 2
  53. q3*q4 *q6 ,
  54. 5
  55. q4 ,
  56. 4 4
  57. q4 *q5 + q4 *q6,
  58. 4 2
  59. q4 *q6 ,
  60. 2 2 2
  61. q4 *q5*q6 - q4 *q6 ,
  62. 2 2
  63. q5 + 3*q6 ,
  64. 3
  65. q6 }
  66. % Example 2. (Little) Trinks problem with 7 polynomials in 6 variables.
  67. trinkspolys:={45*p + 35*s - 165*b - 36,
  68. 35*p + 40*z + 25*t - 27*s,
  69. 15*w + 25*p*s + 30*z - 18*t - 165*b**2,
  70. - 9*w + 15*p*t + 20*z*s,
  71. w*p + 2*z*t - 11*b**3,
  72. 99*w - 11*s*b + 3*b**2,
  73. b**2 + 33/50*b + 2673/10000}$
  74. trinksvars := {w,p,z,t,s,b}$
  75. torder(trinksvars,lex)$
  76. switch varopt;
  77. off varopt;
  78. groebner trinkspolys;
  79. {60000*w + 9500*b + 3969,
  80. 1800*p - 3100*b - 1377,
  81. 18000*z + 24500*b + 10287,
  82. 750*t - 1850*b + 81,
  83. 200*s - 500*b - 9,
  84. 2
  85. 10000*b + 6600*b + 2673}
  86. groesolve ws;
  87. 3*(4*sqrt(11)*i - 11)
  88. {{b=-----------------------,
  89. 100
  90. 62*sqrt(11)*i + 59
  91. p=--------------------,
  92. 300
  93. 3*(5*sqrt(11)*i - 13)
  94. s=-----------------------,
  95. 50
  96. 148*sqrt(11)*i - 461
  97. t=----------------------,
  98. 500
  99. - 190*sqrt(11)*i - 139
  100. w=-------------------------,
  101. 10000
  102. - 490*sqrt(11)*i - 367
  103. z=-------------------------},
  104. 3000
  105. 3*( - 4*sqrt(11)*i - 11)
  106. {b=--------------------------,
  107. 100
  108. - 62*sqrt(11)*i + 59
  109. p=-----------------------,
  110. 300
  111. 3*( - 5*sqrt(11)*i - 13)
  112. s=--------------------------,
  113. 50
  114. - 148*sqrt(11)*i - 461
  115. t=-------------------------,
  116. 500
  117. 190*sqrt(11)*i - 139
  118. w=----------------------,
  119. 10000
  120. 490*sqrt(11)*i - 367
  121. z=----------------------}}
  122. 3000
  123. % Example 3. Hairer, Runge-Kutta 1, 6 polynomials 8 variables.
  124. torder({c2,c3,b3,b2,b1,a21,a32,a31},lex);
  125. {{w,p,z,t,s,b},lex}
  126. groebnerf{c2 - a21,
  127. c3 - a31 - a32,
  128. b1 + b2 + b3 - 1,
  129. b2*c2 + b3*c3 - 1/2,
  130. b2*c2**2 + b3*c3**2 - 1/3,
  131. b3*a32*c2 - 1/6};
  132. {{c2 - a21,
  133. c3 - a32 - a31,
  134. b3 + b2 + b1 - 1,
  135. 2 2 2 2 2 2
  136. 96*b2*b1*a31 - 96*b2*a31 + 96*b2*a31 - 32*b2 - 72*b1 *a32 *a31 - 48*b1 *a32
  137. 2 2 2 2 3 2
  138. - 144*b1 *a32*a31 - 144*b1 *a32*a31 - 72*b1 *a31 + 198*b1*a32 *a31
  139. 2 2 3
  140. + 60*b1*a32 + 396*b1*a32*a31 + 72*b1*a32*a31 - 144*b1*a32 + 198*b1*a31
  141. 2 2
  142. - 108*b1*a31 - 24*b1*a31 - 81*a21*a32*a31 + 54*a21*a32 - 126*a32 *a31
  143. 2 2 3 2
  144. - 12*a32 - 252*a32*a31 + 126*a32*a31 + 36*a32 - 126*a31 + 162*a31
  145. - 30*a31 - 12,
  146. 2 2
  147. 8*b2*a21 - 8*b2*a31 + 6*b1*a32 + 12*b1*a32*a31 + 4*b1*a32 + 6*b1*a31
  148. 2 2
  149. - 4*b1*a31 - 9*a21*a32 - 6*a32 - 12*a32*a31 + 8*a32 - 6*a31 + 10*a31 - 2,
  150. 2 2
  151. 8*b2*a32 + 6*b1*a32 + 12*b1*a32*a31 + 12*b1*a32 + 6*b1*a31 + 4*b1*a31
  152. 2 2
  153. - 9*a21*a32 - 6*a32 - 12*a32*a31 - 6*a31 + 2*a31 + 2,
  154. 2 2 2
  155. 12*b1*a21*a32 - 6*b1*a32 - 12*b1*a32*a31 - 6*b1*a31 - 3*a21*a32 + 6*a32
  156. 2
  157. + 12*a32*a31 - 6*a32 + 6*a31 - 6*a31 + 2,
  158. 2 2
  159. 4*b1*a21*a31 + 2*b1*a32 + 4*b1*a32*a31 + 2*b1*a31 - 3*a21*a32 - 4*a21*a31
  160. 2 2
  161. + 2*a21 - 2*a32 - 4*a32*a31 + 4*a32 - 2*a31 + 4*a31 - 2,
  162. 3 2 2 3 2
  163. 6*b1*a32 + 18*b1*a32 *a31 + 18*b1*a32*a31 + 6*b1*a31 - 9*a21*a32
  164. 3 2 2 2
  165. - 9*a21*a32*a31 + 6*a21*a32 - 6*a32 - 18*a32 *a31 + 12*a32 - 18*a32*a31
  166. 3 2
  167. + 18*a32*a31 - 6*a32 - 6*a31 + 6*a31 - 2*a31,
  168. 2 2 2
  169. 3*a21 *a32 - 3*a21*a32 - a21*a31 + a32 + 2*a32*a31 + a31 }}
  170. % The examples 4 and 5 use automatic variable extraction.
  171. % Example 4.
  172. torder gradlex$
  173. g4:=
  174. groebner{b + e + f - 1,
  175. c + d + 2*e - 3,
  176. b + d + 2*f - 1,
  177. a - b - c - d - e - f,
  178. d*e*a**2 - 1569/31250*b*c**3,
  179. c*f - 587/15625*b*d};
  180. 5
  181. g4 := {144534461790680056924571742971580442350868*f
  182. 4
  183. - 644899801559202566371326081182412388593750*f
  184. 2
  185. - 5642454222593591361522253644740080176968509*e*f
  186. 3
  187. + 1026970650200404602876625225711718032483739*f
  188. + 60671378319336814425425106786936647125250*e*f
  189. 2
  190. + 12135463840178290842421221291430776956948795*f
  191. + 82342665293813692270756265387326300721851*e
  192. - 6546572608747272255841866021042619274525791*f
  193. - 455593441982762135422235490670177670637,
  194. 3 4
  195. 8282838608877853969*e*f - 2667985333760708531*f
  196. 2 3
  197. - 315490964385538173*e*f - 8319462093247392142*f - 25594942638053*e*f
  198. 2
  199. + 318993777538462620*f + 33851175608089*e + 34163367871142*f
  200. - 8568425233089,
  201. 2 2
  202. 587*e - 46875*e*f + 15038*f - 587*e + 47462*f,
  203. a + 2*e - 4,
  204. b + e + f - 1,
  205. c + 3*e - f - 3,
  206. d - e + f}
  207. hilbertpolynomial g4;
  208. 8
  209. glexconvert(g4,gvarslast,newvars={e},maxdeg=8);
  210. 8 7
  211. {8724935291855297898986*e - 82886885272625330040367*e
  212. 6 5
  213. + 304980377204235125220384*e - 524915947547338451201596*e
  214. 4 3
  215. + 362375013966993813907616*e + 52719473339686639067952*e
  216. 2
  217. - 154986762992209058701440*e + 27347344067139574366944*e + 430203494102932512
  218. }
  219. % Example 5.
  220. off varopt;
  221. torder({u0,u2,u3,u1},lex)$
  222. groesolve({u0**2 - u0 + 2*u1**2 + 2*u2**2 + 2*u3**2,
  223. 2*u0*u1 + 2*u1*u2 + 2*u2*u3 - u1,
  224. 2*u0*u2 + u1**2 + 2*u1*u3 - u2,
  225. u0 + 2*u1 + 2*u2 + 2*u3 - 1},
  226. {u0,u2,u3,u1});
  227. {{u0=1,u2=0,u3=0,u1=0},
  228. 1 1
  229. {u0=---,u2=0,u3=---,u1=0},
  230. 3 3
  231. 5 4 3 2
  232. {u0=(85796172*u1 - 47481552*u1 - 10265256*u1 + 4828462*u1 + 414200*u1
  233. - 24707)/164805,
  234. 5 4 3 2
  235. u2=(490926744*u1 - 82790424*u1 - 46802952*u1 + 5425849*u1 + 1108070*u1
  236. - 83819)/164805,
  237. u3
  238. 5 4 3 2
  239. - 35588322*u1 + 7102080*u1 + 3462372*u1 - 522672*u1 - 98665*u1 + 11905
  240. =-----------------------------------------------------------------------------
  241. 10987
  242. ,
  243. 6 5 4 3 2
  244. u1=root_of(24948*u1_ - 8424*u1_ - 1908*u1_ + 736*u1_ + 24*u1_ - 18*u1_
  245. + 1,u1_,tag_1)}}
  246. % Example 6. (Big) Trinks problem with 6 polynomials in 6 variables.
  247. torder(trinksvars,lex)$
  248. btbas:=
  249. groebner{45*p + 35*s - 165*b - 36,
  250. 35*p + 40*z + 25*t - 27*s,
  251. 15*w + 25*p*s + 30*z - 18*t - 165*b**2,
  252. -9*w + 15*p*t + 20*z*s,
  253. w*p + 2*z*t - 11*b**3,
  254. 99*w - 11*b*s + 3*b**2};
  255. btbas := {17766149161458472422166115589155691471353640232570952361584640*w
  256. 9
  257. + 3032932981764169411024286535087872715152793150994240000000000000*b
  258. + 11886822444254795859791802829918904596379497649520730600000000000
  259. 8
  260. *b +
  261. 7
  262. 18842475008351431516615767365088235858572104823839818660000000000*b +
  263. 6
  264. 18478618789454571665641479626067848900525899492180377333740000000*b
  265. 5
  266. + 11752365113063961011548983119538614396423298749092231098450400000*b
  267. 4
  268. + 5110161259755495688253057699488605142801193206234091633443430000*b
  269. 3
  270. + 1496961750963944475883560598484727796781670457510019079125319720*b
  271. 2
  272. + 288690575257721822668492218552623049380964882774348400629792405*b
  273. + 36675221781192845731725910375461662443650512572339688148737880*b
  274. + 1576363174251807401047861085627012261518448811764870474808048,
  275. 1079293561558602199646591522041208256884733644128685355966266880*p +
  276. 9
  277. 3268477702530974927415861070452491173139572636038856000000000000000*b
  278. +
  279. 12885633343818230635528913313274512975854362843839764665000000000000
  280. 8
  281. *b +
  282. 20548731096300848092222002490748474767709483225818633322500000000000
  283. 7
  284. *b +
  285. 20182049540868333737979937480097593847242554499522522583343500000000
  286. 6
  287. *b +
  288. 12840592651209104850152262711039251760751322701157046861979660000000
  289. 5
  290. *b +
  291. 4
  292. 5569707184558884260455460870514004047533638259197462099687709750000*b
  293. + 1626104523905067336734029117969017435050069455164231436772691393000
  294. 3
  295. *b +
  296. 2
  297. 317837165064133808425156860561547977935248864650364953213370433325*b
  298. + 38814916107963233682867824475195786374043607759221055124383464600*b
  299. + 1271557117681971715777755868970298734422034654142333039426477936,
  300. 79947671226563125899747520151200611621091381046569285627130880*z -
  301. 9
  302. 207000360174268878618253807286221414267374039050881600000000000000*b
  303. - 816930976846005632807581869594187232031930825060787069000000000000
  304. 8
  305. *b -
  306. 7
  307. 1304191848597021137419209873493260430019068809677834324500000000000*b
  308. - 1281648951757969533154633755921969360988365079018184794999100000000
  309. 6
  310. *b -
  311. 5
  312. 816111850476984294981540451378918253659030380648143145999676000000*b
  313. - 354123157925898223808181474698490366723104830470028121053590350000
  314. 4
  315. *b -
  316. 3
  317. 103524414072393919562685172085266423030522292688870620316927889800*b
  318. 2
  319. - 20314259597530323830287024948271996904872237353588201428371308545*b
  320. - 2537917907646239051588678539186026277776904294491429226344955896*b
  321. - 101754994043218022355542895254001231074817584410141704072917808,
  322. 53964678077930109982329576102060412844236682206434267798313344*t -
  323. 9
  324. 232158787821822686686268803096828213303267879649894080000000000000*b
  325. - 914339994087255788035842922803409884324637299732580010200000000000
  326. 8
  327. *b -
  328. 7
  329. 1456553024942306848445635398194494646048613632462079804220000000000*b
  330. - 1429773468085320579659912540829309032262384742022357855878580000000
  331. 6
  332. *b -
  333. 5
  334. 908944691139155009098308941935669674404431611232759364790656800000*b
  335. - 394123305458525780887811122985868682566594060374758630590008810000
  336. 4
  337. *b -
  338. 3
  339. 114919063563435384108358931167592408356874179358918284670595993240*b
  340. 2
  341. - 22376181506466478409426169614162075694852682500804198791108921475*b
  342. - 2945714266609139709176973289117451707834537151497408879223183208*b
  343. - 127343046946408668687682889109197718306724189305639804298381200,
  344. 23984301367968937769924256045360183486327414313970785688139264*s -
  345. 9
  346. 93385077215170712211881744870071176375416361029681600000000000000*b -
  347. 8
  348. 368160952680520875300826094664986085024410366966850419000000000000*b
  349. - 587106602751452802634914356878527850505985235023389523500000000000
  350. 7
  351. *b -
  352. 6
  353. 576629986881952392513712499431359824206930128557786359524100000000*b
  354. - 366874075748831567147207506029692907450037791461629910342276000000
  355. 5
  356. *b -
  357. 4
  358. 159134490987396693155870310586114401358103950262784631419648850000*b
  359. 3
  360. - 46460129254430495335257974799114783858573413004692326764934039800*b
  361. 2
  362. - 9081061858975251669290196016044227941007110418581855806096298095*b
  363. - 1222066452390803097568723620648006189979646603457892421797898376*b
  364. - 60999770483681527871286545331521866855137759127008037834271184,
  365. 10 9
  366. 43808000000000000000*b + 189995300000000000000*b
  367. 8 7
  368. + 343169730200000000000*b + 377900184178000000000*b
  369. 6 5
  370. + 277427432368460000000*b + 141636786601439800000*b
  371. 4 3
  372. + 50921375336016834000*b + 12792266529459977340*b
  373. 2
  374. + 2215667232541084905*b + 237653554658069880*b + 8984801833047216}
  375. % The above system has dimension zero. Therefore its Hilbert polynomial
  376. % is a constant which is the number of zero points (including complex
  377. % zeros and multipliticities);
  378. hilbertpolynomial ws;
  379. 10
  380. % Example of Groebner with numerical postprocessing.
  381. on rounded;
  382. off varopt;
  383. groesolve(trinkspolys,trinksvars);
  384. {{b= - 0.397994974843*i - 0.33,
  385. p= - 0.685435790007*i + 0.196666666667,
  386. s= - 0.994987437107*i - 0.78,
  387. t= - 0.981720937945*i - 0.922,
  388. w=0.0630158710168*i - 0.0139,
  389. z=0.541715382425*i - 0.122333333333},
  390. {b=0.397994974843*i - 0.33,
  391. p=0.685435790007*i + 0.196666666667,
  392. s=0.994987437107*i - 0.78,
  393. t=0.981720937945*i - 0.922,
  394. w= - 0.0630158710168*i - 0.0139,
  395. z= - 0.541715382425*i - 0.122333333333}}
  396. off rounded;
  397. % Additional groebner operators.
  398. % Reduce one polynomial wrt the basis of big Trinks. The result 0
  399. % is a proof for the ideal membership of the polynomial.
  400. torder(trinksvars,lex)$
  401. preduce(45*p + 35*s - 165*b - 36,btbas);
  402. 0
  403. % The following examples show how to work with the distributive
  404. % form of polynomials.
  405. torder({u0,u1,u2,u3},gradlex)$
  406. gsplit(2*u0*u2 + u1**2 + 2*u1*u3 - u2,{u0,u1,u2,u3});
  407. 2
  408. {2*u0*u2,u1 + 2*u1*u3 - u2}
  409. torder(trinksvars,lex)$
  410. gsort trinkspolys;
  411. 3
  412. {w*p + 2*z*t - 11*b ,
  413. 2
  414. 99*w - 11*s*b + 3*b ,
  415. - 9*w + 15*p*t + 20*z*s,
  416. 2
  417. 15*w + 25*p*s + 30*z - 18*t - 165*b ,
  418. 35*p + 40*z + 25*t - 27*s,
  419. 45*p + 35*s - 165*b - 36,
  420. 2 33 2673
  421. b + ----*b + -------}
  422. 50 10000
  423. gspoly(first trinkspolys,second trinkspolys);
  424. 360*z + 225*t - 488*s + 1155*b + 252
  425. gvars trinkspolys;
  426. {w,p,z,t,s,b}
  427. % Tagged basis and reduction trace. A tagged basis is a basis where
  428. % each polynomial is equated to a linear combination of the input
  429. % set. A tagged reduction shows how the result is computed by using
  430. % the basis polynomials.
  431. % First example for tagged polynomials: show how a polynomial is
  432. % represented as linear combination of the basis polynomials.
  433. % First I set up an environment for the computation.
  434. torder(trinksvars,lex)$
  435. % Then I compute an ordinary Groebner basis.
  436. bas:=groebner trinkspolys$
  437. % Next I assign a tag to each basis polynomial.
  438. taggedbas:=for i:=1:length bas collect mkid(p,i)=part(bas,i);
  439. taggedbas := {p1=9500*b + 60000*w + 3969,
  440. p2= - 3100*b + 1800*p - 1377,
  441. p3=24500*b + 18000*z + 10287,
  442. p4= - 1850*b + 750*t + 81,
  443. p5= - 500*b + 200*s - 9,
  444. 2
  445. p6=10000*b + 6600*b + 2673}
  446. % And finally I reduce a (tagged) polynomial wrt the tagged basis.
  447. preducet(new=w*p + 2*z*t - 11*b**3,taggedbas);
  448. 3 2
  449. 857375000000*p*w + 1714750000000*t*z + 2376000000000000*w + 471517200000000*w
  450. 2
  451. + 31190862780000*w + 687758524299=992750000*b *p1 - 6270000000*b*p1*w
  452. 2
  453. - 414760500*b*p1 + 857375000000*new + 39600000000*p1*w + 5239080000*p1*w
  454. + 173282571*p1
  455. % Second example for tagged polynomials: representing a Groebner basis
  456. % as a combination of the input polynomials, here in a simple geometric
  457. % problem.
  458. torder({x,y},lex)$
  459. groebnert {circle=x**2 + y**2 - r**2,line=a*x + b*y};
  460. left
  461. ------------------------------------------------------------------------------
  462. >> accum. cpu time : 0 ms
  463. left
  464. ------------------------------------------------------------------------------
  465. >> accum. cpu time : 0 ms
  466. { - a*x - b*y= - line,
  467. 2 2 2 2 2 2
  468. (a + b )*y - a *r =a *circle - a*line*x + b*line*y}
  469. % In the third example I enter two polynomials that have no common zero.
  470. % Consequently the basis is {1}. The tagged computation gives me a proof
  471. % for the inconsistency of the system which is independent of the
  472. % Groebner formalism.
  473. groebnert {circle1=x**2 + y**2 - 10,circle2=x**2 + y**2 - 2};
  474. - circle1 + circle2
  475. {1=----------------------}
  476. 8
  477. % Solve a special elimination task by using a blockwise elimination
  478. % order defined by a matrix. The equation set goes back to A.M.H.
  479. % Levelt (Nijmegen). The question is whether there is a member in the
  480. % ideal which depends only on two variables. Here we select x4 and y1.
  481. % The existence of such a polynomial proves that the system has exactly
  482. % one degree of freedom.
  483. % The first two rows of the term order matrix define the groupwise
  484. % elimination. The remaining lines define a secondary local
  485. % lexicographical behavior which is needed to construct an admissible
  486. % ordering.
  487. f1:=y1^2 + z1^2 -1;
  488. 2 2
  489. f1 := y1 + z1 - 1
  490. f2:=x2^2 + y2^2 + z2^2 -1;
  491. 2 2 2
  492. f2 := x2 + y2 + z2 - 1
  493. f3:=x3^2 + y3^2 + z3^2 -1;
  494. 2 2 2
  495. f3 := x3 + y3 + z3 - 1
  496. f4:=x4^2 + z4^2 -1;
  497. 2 2
  498. f4 := x4 + z4 - 1
  499. f5:=y1*y2 + z1*z2;
  500. f5 := y1*y2 + z1*z2
  501. f6:=x2*x3 + y2*y3 + z2*z3;
  502. f6 := x2*x3 + y2*y3 + z2*z3
  503. f7:=x3*x4 + z3*z4;
  504. f7 := x3*x4 + z3*z4
  505. f8:=x2 + x3 + x4 + 1;
  506. f8 := x2 + x3 + x4 + 1
  507. f9:=y1 + y2 + y3 - 1;
  508. f9 := y1 + y2 + y3 - 1
  509. f10:=z1 + z2 + z3 + z4;
  510. f10 := z1 + z2 + z3 + z4
  511. eqns:={f1,f2,f3,f4,f5,f6,f7,f8,f9,f10}$
  512. vars:={x2,x3,y2,y3,z1,z2,z3,z4,x4,y1}$
  513. torder(vars,matrix,
  514. mat((1,1,1,1,1,1,1,1,0,0),
  515. (0,0,0,0,0,0,0,0,1,1),
  516. (1,0,0,0,0,0,0,0,0,0),
  517. (0,1,0,0,0,0,0,0,0,0),
  518. (0,0,1,0,0,0,0,0,0,0),
  519. (0,0,0,1,0,0,0,0,0,0),
  520. (0,0,0,0,1,0,0,0,0,0),
  521. (0,0,0,0,0,1,0,0,0,0),
  522. (0,0,0,0,0,0,1,0,0,0),
  523. (0,0,0,0,0,0,0,0,1,0)));
  524. {{x,y},lex}
  525. first reverse groebner(eqns,vars);
  526. 2 2 2 2
  527. x4 *y1 - 2*x4 + 2*x4*y1 - 2*x4 - 2*y1 + 2*y1
  528. % For a faster execution we convert the matrix into a
  529. % proper machine code routine.
  530. on comp;
  531. torder_compile(levelt,mat(
  532. (1,1,1,1,1,1,1,1,0,0),
  533. (0,0,0,0,0,0,0,0,1,1),
  534. (1,0,0,0,0,0,0,0,0,0),
  535. (0,1,0,0,0,0,0,0,0,0),
  536. (0,0,1,0,0,0,0,0,0,0),
  537. (0,0,0,1,0,0,0,0,0,0),
  538. (0,0,0,0,1,0,0,0,0,0),
  539. (0,0,0,0,0,1,0,0,0,0),
  540. (0,0,0,0,0,0,1,0,0,0),
  541. (0,0,0,0,0,0,0,0,1,0)));
  542. +++ levelt compiled, 324 + 16 bytes
  543. levelt
  544. torder(vars,levelt)$
  545. first reverse groebner(eqns,vars);
  546. 2 2 2 2
  547. x4 *y1 - 2*x4 + 2*x4*y1 - 2*x4 - 2*y1 + 2*y1
  548. % For a homogeneous polynomial set we compute a graded Groebner
  549. % basis with grade limits. We use the graded term order with lex
  550. % as following order. As the grade vector has no zeros, this ordering
  551. % is functionally equivalent to a weighted ordering.
  552. torder({x,y,z},graded,{1,1,2},lex);
  553. {{x2,x3,y2,y3,z1,z2,z3,z4,x4,y1},levelt}
  554. dd_groebner(0,10,{x^10*y + y*z^5, x*y^12 + y*z^6});
  555. 12 6 10 5
  556. {x*y + y*z ,x *y + y*z }
  557. dd_groebner(0,50,{x^10*y + y*z^5, x*y^12 + y*z^6});
  558. 7 18 34 5
  559. {x *y*z - y *z ,
  560. 8 12 23 5
  561. x *y*z + y *z ,
  562. 9 6 12 5
  563. x *y*z - y *z ,
  564. 12 6
  565. x*y + y*z ,
  566. 10 5
  567. x *y + y*z }
  568. dd_groebner(0,infinity,{x^10*y + y*z^5, x*y^12 + y*z^6});
  569. 111 5 60
  570. {y *z + y*z ,
  571. 54 100 5
  572. x*y*z - y *z ,
  573. 2 48 89 5
  574. x *y*z + y *z ,
  575. 3 42 78 5
  576. x *y*z - y *z ,
  577. 4 36 67 5
  578. x *y*z + y *z ,
  579. 5 30 56 5
  580. x *y*z - y *z ,
  581. 6 24 45 5
  582. x *y*z + y *z ,
  583. 7 18 34 5
  584. x *y*z - y *z ,
  585. 8 12 23 5
  586. x *y*z + y *z ,
  587. 9 6 12 5
  588. x *y*z - y *z ,
  589. 12 6
  590. x*y + y*z ,
  591. 10 5
  592. x *y + y*z }
  593. % Test groebner_walk
  594. trinkspolys := {45*p + 35*s - 165*b - 36,
  595. 35*p + 40*z + 25*t - 27*s,
  596. 15*w + 25*p*s + 30*z - 18*t - 165*b**2,
  597. - 9*w + 15*p*t + 20*z*s,
  598. w*p + 2*z*t - 11*b**3,
  599. 99*w - 11*s*b + 3*b**2,
  600. b**2 + 33/50*b + 2673/10000}$
  601. trinksvars := {w,p,z,t,s,b}$
  602. torder(trinksvars,gradlex)$
  603. gg:=groebner trinkspolys$
  604. g:=groebner_walk gg$
  605. on div$
  606. g;
  607. 2 33 2673
  608. {b + ----*b + -------,
  609. 50 10000
  610. 19 1323
  611. -----*b + w + -------,
  612. 120 20000
  613. 31 153
  614. - ----*b + p - -----,
  615. 18 200
  616. 49 1143
  617. ----*b + z + ------,
  618. 36 2000
  619. 37 27
  620. - ----*b + t + -----,
  621. 15 250
  622. 5 9
  623. - ---*b + s - -----}
  624. 2 200
  625. on varopt;
  626. g1:=solve({first g},{b});
  627. 3 33
  628. g1 := {b=----*sqrt(11)*i - -----,
  629. 25 100
  630. 3 33
  631. b= - ----*sqrt(11)*i - -----}
  632. 25 100
  633. g0:=sub({first g1},g);
  634. g0 := {0,
  635. 19 139
  636. ------*sqrt(11)*i + w + -------,
  637. 1000 10000
  638. 31 59
  639. - -----*sqrt(11)*i + p - -----,
  640. 150 300
  641. 49 367
  642. -----*sqrt(11)*i + z + ------,
  643. 300 3000
  644. 37 461
  645. - -----*sqrt(11)*i + t + -----,
  646. 125 500
  647. 3 39
  648. - ----*sqrt(11)*i + s + ----}
  649. 10 50
  650. solve({ second g0},{w});
  651. 19 139
  652. {w= - ------*sqrt(11)*i - -------}
  653. 1000 10000
  654. solve({third g0},{p});
  655. 31 59
  656. {p=-----*sqrt(11)*i + -----}
  657. 150 300
  658. solve({part(g0,4)},{z});
  659. 49 367
  660. {z= - -----*sqrt(11)*i - ------}
  661. 300 3000
  662. solve({part(g0,5)},{t});
  663. 37 461
  664. {t=-----*sqrt(11)*i - -----}
  665. 125 500
  666. solve({part(g0,6)},{s});
  667. 3 39
  668. {s=----*sqrt(11)*i - ----}
  669. 10 50
  670. g0:=sub({second g1},g);
  671. g0 := {0,
  672. 19 139
  673. - ------*sqrt(11)*i + w + -------,
  674. 1000 10000
  675. 31 59
  676. -----*sqrt(11)*i + p - -----,
  677. 150 300
  678. 49 367
  679. - -----*sqrt(11)*i + z + ------,
  680. 300 3000
  681. 37 461
  682. -----*sqrt(11)*i + t + -----,
  683. 125 500
  684. 3 39
  685. ----*sqrt(11)*i + s + ----}
  686. 10 50
  687. solve({second g0},{w});
  688. 19 139
  689. {w=------*sqrt(11)*i - -------}
  690. 1000 10000
  691. solve({third g0},{p});
  692. 31 59
  693. {p= - -----*sqrt(11)*i + -----}
  694. 150 300
  695. solve({part(g0,4)},{z});
  696. 49 367
  697. {z=-----*sqrt(11)*i - ------}
  698. 300 3000
  699. solve({part(g0,5)},{t});
  700. 37 461
  701. {t= - -----*sqrt(11)*i - -----}
  702. 125 500
  703. solve({part(g0,6)},{s});
  704. 3 39
  705. {s= - ----*sqrt(11)*i - ----}
  706. 10 50
  707. % Example after the book "David Cox, John Little, Donal O'Shea:
  708. % "Ideals, Varieties and Algorithms", chapter 2, paragraph 8, example 3.
  709. % This example was given by Shigetoshi Katsura (Japan).
  710. off groebopt;
  711. torder({x,y,z,l},lex);
  712. {{w,p,z,t,s,b},gradlex,1,0,0,0,0,0}
  713. g:=groebner{3*x^2+2*y*z-2*x*l,2*x*z-2*y*l,2*x*y-2*z-2*z*l,x^2+y^2+z^2-1}$
  714. gdimension g;
  715. 0
  716. gindependent_sets g;
  717. {{}}
  718. clear g, gg, trinkspolys, trinksvars$
  719. end;
  720. Time for test: 510 ms, plus GC time: 10 ms