normform.rlg 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290
  1. Tue Apr 15 00:34:38 2008 run on win32
  2. *** co already defined as operator
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. % %
  5. % Examples of calculations of matrix normal forms using the REDUCE %
  6. % NORMFORM package. %
  7. % %
  8. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. % load_package normform;
  10. on errcont;
  11. % So that computation continues after an error.
  12. %
  13. % If using xr, the X interface for REDUCE, then turn on looking_good to
  14. % improve the appearance of the output.
  15. %
  16. fluid '(options!*);
  17. lisp if memq('fmprint ,options!*) then on looking_good;
  18. procedure test(tmp,A);
  19. %
  20. % Checks that P * N * P^-1 = A where tmp is the output {P,N,P^-1}
  21. % of the Normal form calculation on A.
  22. %
  23. begin
  24. if second tmp * first tmp * third tmp = A then
  25. write "Seems O.K." else rederr "something isn't working.";
  26. end;
  27. test
  28. %%%%%%%%%%%%%%%%%%%%%%%%%%%% Smithex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  29. A := mat((3*x,x^2+x),(0,x^2));
  30. [3*x x*(x + 1)]
  31. [ ]
  32. a := [ 2 ]
  33. [ 0 x ]
  34. answer := smithex(A,x);
  35. answer := {
  36. [x 0 ]
  37. [ ]
  38. [ 2]
  39. [0 x ]
  40. ,
  41. [1 0]
  42. [ ]
  43. [x 1]
  44. ,
  45. [3 x + 1]
  46. [ ]
  47. [-3 - x ]
  48. }
  49. test(answer,A);
  50. Seems O.K.
  51. %
  52. % Extend algebraic field to include sqrt2.
  53. %
  54. load_package arnum;
  55. defpoly sqrt2**2-2;
  56. A := mat((sqrt2*y^2,y+1),(3*sqrt2,y^3+y*sqrt2));
  57. [ 2 ]
  58. [sqrt2*y y + 1 ]
  59. a := [ ]
  60. [ 2 ]
  61. [3*sqrt2 y*(y + sqrt2)]
  62. answer := smithex(A,y);
  63. answer := {
  64. [1 0 ]
  65. [ ]
  66. [ 5 3 ]
  67. [0 y + sqrt2*y - 3*y - 3]
  68. ,
  69. [ 2 1 ]
  70. [sqrt2*y ---*sqrt2]
  71. [ 6 ]
  72. [ ]
  73. [3*sqrt2 0 ]
  74. ,
  75. [ 1 2 ]
  76. [1 ---*sqrt2*y*(y + sqrt2)]
  77. [ 6 ]
  78. [ ]
  79. [0 - sqrt2 ]
  80. }
  81. test(answer,A);
  82. Seems O.K.
  83. off arnum;
  84. %
  85. % smithex will compute the Smith normal form of matrices containing
  86. % only integer entries but the integers are regarded as univariate
  87. % polynomials in x over a field F (the rationals unless the field has
  88. % been extended). For calculations over the integers use smithex_int.
  89. %
  90. A := mat((9,-36,30),(-36,192,-180),(30,-180,180));
  91. [ 9 -36 30 ]
  92. [ ]
  93. a := [-36 192 -180]
  94. [ ]
  95. [30 -180 180 ]
  96. answer := smithex(A,x);
  97. *** WARNING: all matrix entries are integers.
  98. If calculations in Z(the integers) are required, use smithex_int.
  99. answer := {
  100. [1 0 0]
  101. [ ]
  102. [0 1 0]
  103. [ ]
  104. [0 0 1]
  105. ,
  106. [ 1 ]
  107. [ 9 18 -----]
  108. [ 720 ]
  109. [ ]
  110. [-36 -24 0 ]
  111. [ ]
  112. [30 0 0 ]
  113. ,
  114. [1 -6 6 ]
  115. [ ]
  116. [ - 3 ]
  117. [0 1 ------]
  118. [ 2 ]
  119. [ ]
  120. [0 0 2160 ]
  121. }
  122. test(answer,A);
  123. Seems O.K.
  124. %%%%%%%%%%%%%%%%%%%%%%%%%%%% Smithex_int %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  125. A := mat((1,2,3),(4,5,6),(7,8,x));
  126. [1 2 3]
  127. [ ]
  128. a := [4 5 6]
  129. [ ]
  130. [7 8 x]
  131. answer := smithex_int(A);
  132. ***** ERROR: matrix contains non_integer entries. Try smithex.
  133. A := mat((9,-36,30),(-36,192,-180),(30,-180,180));
  134. [ 9 -36 30 ]
  135. [ ]
  136. a := [-36 192 -180]
  137. [ ]
  138. [30 -180 180 ]
  139. answer := smithex_int(A);
  140. answer := {
  141. [3 0 0 ]
  142. [ ]
  143. [0 12 0 ]
  144. [ ]
  145. [0 0 60]
  146. ,
  147. [-17 -5 -4 ]
  148. [ ]
  149. [64 19 15 ]
  150. [ ]
  151. [-50 -15 -12]
  152. ,
  153. [1 -24 30 ]
  154. [ ]
  155. [-1 25 -30]
  156. [ ]
  157. [0 -1 1 ]
  158. }
  159. test(answer,A);
  160. Seems O.K.
  161. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Frobenius %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  162. A := mat(((y+y^2-x^2)/y,(x-x^2-y+y^2)/y,(x^2-y^2)/y),(1+x+y,
  163. (x-y+y^2+x*y)/y,-x-y),((y-x+y^2-x^2)/y,(x-y+y^2-x^2)/y,
  164. (x+x^2-y^2)/y));
  165. [ 2 2 2 2 2 2 ]
  166. [ - x + y + y - x + x + y - y x - y ]
  167. [ ---------------- -------------------- --------- ]
  168. [ y y y ]
  169. [ ]
  170. [ 2 ]
  171. [ x*y + x + y - y ]
  172. a := [ x + y + 1 ------------------ - (x + y) ]
  173. [ y ]
  174. [ ]
  175. [ 2 2 2 2 2 2 ]
  176. [ - x - x + y + y - x + x + y - y x + x - y ]
  177. [-------------------- -------------------- -------------]
  178. [ y y y ]
  179. answer := frobenius(A);
  180. answer := {
  181. [ x ]
  182. [--- 0 0 ]
  183. [ y ]
  184. [ ]
  185. [ - x*(x + y) ]
  186. [ 0 0 --------------]
  187. [ y ]
  188. [ ]
  189. [ 2 ]
  190. [ x*y + x + y ]
  191. [ 0 1 --------------]
  192. [ y ]
  193. ,
  194. 3 2 2 2 2 2 2
  195. - x - 2*x *y - x - x*y + x*y + 2*y + y x - y - y
  196. mat((---------------------------------------------,-1,-------------),
  197. y*(x + y + 1) y
  198. (x + y + 1,0, - (x + y + 1)),
  199. 2 2 2 2
  200. - x - x + y + 2*y x + x - y - y
  201. (----------------------,0,-----------------))
  202. y y
  203. ,
  204. [ x - y ]
  205. [0 ------- 1 ]
  206. [ y ]
  207. [ ]
  208. [ 3 2 2 2 3 2 2 2 ]
  209. [ - x - x *y - x + x*y + y + y + y - x - 2*x*y - y ]
  210. [-1 ---------------------------------------- --------------------]
  211. [ y*(x + y + 1) x + y + 1 ]
  212. [ ]
  213. [ 2 2 ]
  214. [ x + x - y - 2*y ]
  215. [0 ------------------- 1 ]
  216. [ y*(x + y + 1) ]
  217. }
  218. test(answer,A);
  219. Seems O.K.
  220. %
  221. % Extend algebraic field to include i.
  222. %
  223. % load_package arnum;
  224. defpoly i^2+1;
  225. A := mat((-3-i,1,2+i,7-9*i),(-2,1,1,5-i),(-2-2*i,1,2+2*i,4-2*i),
  226. (2,0,-1,-2+8*i));
  227. [ - (i + 3) 1 i + 2 - (9*i - 7)]
  228. [ ]
  229. [ -2 1 1 - (i - 5) ]
  230. a := [ ]
  231. [ - (2*i + 2) 1 2*i + 2 - (2*i - 4)]
  232. [ ]
  233. [ 2 0 -1 8*i - 2 ]
  234. answer := frobenius(A);
  235. answer := {
  236. [i + 1 0 0 0 ]
  237. [ ]
  238. [ 0 0 0 7*i - 3 ]
  239. [ ]
  240. [ 0 1 0 - (8*i - 9)]
  241. [ ]
  242. [ 0 0 1 8*i - 3 ]
  243. ,
  244. [ 425 189 ]
  245. [-----*i + ----- -1 i + 3 18*i - 18 ]
  246. [ 106 106 ]
  247. [ ]
  248. [ 634 258 ]
  249. [-----*i + ----- 0 2 2*i - 12 ]
  250. [ 53 53 ]
  251. [ ]
  252. [ 150 588 ]
  253. [-----*i - ----- 0 2*i + 2 4*i - 10 ]
  254. [ 53 53 ]
  255. [ ]
  256. [ 108 7 ]
  257. [-----*i + ---- 0 -2 - (16*i - 8)]
  258. [ 53 53 ]
  259. ,
  260. mat((0, - i,1,1),
  261. 143 268 263 152 491 155
  262. (-1, - (-----*i - -----),-----*i + -----,-----*i + -----),
  263. 53 53 53 53 106 106
  264. 339 368 392 383 370 189
  265. (0, - (-----*i + -----), - (-----*i - -----), - (-----*i - -----)
  266. 106 53 53 106 53 53
  267. ),
  268. 101 9 7 54
  269. (0, - (-----*i + -----), - (-----*i - ----),1))
  270. 106 106 106 53
  271. }
  272. off arnum;
  273. A := mat((10,-5,-5,8,3,0),(-4,2,-10,-7,-5,-5),(-8,2,7,3,7,5),
  274. (-6,-7,-7,-7,10,7),(-4,-3,-3,-6,8,-9),(-2,5,-5,9,7,-4));
  275. [10 -5 -5 8 3 0 ]
  276. [ ]
  277. [-4 2 -10 -7 -5 -5]
  278. [ ]
  279. [-8 2 7 3 7 5 ]
  280. a := [ ]
  281. [-6 -7 -7 -7 10 7 ]
  282. [ ]
  283. [-4 -3 -3 -6 8 -9]
  284. [ ]
  285. [-2 5 -5 9 7 -4]
  286. F := first frobenius(A);
  287. [0 0 0 0 0 -867960]
  288. [ ]
  289. [1 0 0 0 0 -466370]
  290. [ ]
  291. [0 1 0 0 0 47845 ]
  292. f := [ ]
  293. [0 0 1 0 0 -712 ]
  294. [ ]
  295. [0 0 0 1 0 -95 ]
  296. [ ]
  297. [0 0 0 0 1 16 ]
  298. %
  299. % Calculate in Z\23Z...
  300. %
  301. on modular;
  302. setmod 23;
  303. 1
  304. F_mod := first frobenius(A);
  305. [0 17 0 0 0 0 ]
  306. [ ]
  307. [1 19 0 0 0 0 ]
  308. [ ]
  309. [0 0 0 0 0 10]
  310. f_mod := [ ]
  311. [0 0 1 0 0 5 ]
  312. [ ]
  313. [0 0 0 1 0 15]
  314. [ ]
  315. [0 0 0 0 1 20]
  316. %
  317. % ...and with a balanced modular representation.
  318. %
  319. on balanced_mod;
  320. F_bal_mod := first frobenius(A);
  321. [0 - 6 0 0 0 0 ]
  322. [ ]
  323. [1 - 4 0 0 0 0 ]
  324. [ ]
  325. [0 0 0 0 0 10 ]
  326. f_bal_mod := [ ]
  327. [0 0 1 0 0 5 ]
  328. [ ]
  329. [0 0 0 1 0 - 8]
  330. [ ]
  331. [0 0 0 0 1 - 3]
  332. off balanced_mod;
  333. off modular;
  334. %%%%%%%%%%%%%%%%%%%%%%%%%%% Ratjordan %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  335. A := mat(((y+y^2-x^2)/y,(x-x^2-y+y^2)/y,(x^2-y^2)/y),(1+x+y,
  336. (x-y+y^2+x*y)/y,-x-y),((y-x+y^2-x^2)/y,(x-y+y^2-x^2)/y,
  337. (x+x^2-y^2)/y));
  338. [ 2 2 2 2 2 2 ]
  339. [ - x + y + y - x + x + y - y x - y ]
  340. [ ---------------- -------------------- --------- ]
  341. [ y y y ]
  342. [ ]
  343. [ 2 ]
  344. [ x*y + x + y - y ]
  345. a := [ x + y + 1 ------------------ - (x + y) ]
  346. [ y ]
  347. [ ]
  348. [ 2 2 2 2 2 2 ]
  349. [ - x - x + y + y - x + x + y - y x + x - y ]
  350. [-------------------- -------------------- -------------]
  351. [ y y y ]
  352. answer := ratjordan(A);
  353. answer := {
  354. [ x ]
  355. [--- 0 0 ]
  356. [ y ]
  357. [ ]
  358. [ x ]
  359. [ 0 --- 0 ]
  360. [ y ]
  361. [ ]
  362. [ 0 0 x + y]
  363. ,
  364. 3 2 2 2 2 2
  365. - x - 2*x *y - x - x*y + x*y + 2*y + y - x - x*y + y
  366. mat((---------------------------------------------,-----------------,
  367. y*(x + y + 1) 2
  368. x*y - x + y
  369. 2 2
  370. x + x - y - y
  371. -----------------),
  372. 2
  373. x*y - x + y
  374. y*(x + y + 1) - y*(x + y + 1)
  375. (x + y + 1,---------------,------------------),
  376. 2 2
  377. x*y - x + y x*y - x + y
  378. 2 2 2 2 2 2
  379. - x - x + y + 2*y - x - x + y + y x + x - y - y
  380. (----------------------,--------------------,-----------------))
  381. y 2 2
  382. x*y - x + y x*y - x + y
  383. ,
  384. x - y
  385. mat((0,-------,1),
  386. y
  387. 3 3 2 2 2 2 3 2 4 3 2
  388. - x *y + x - x *y - x *y + x + x*y - x*y - 2*x*y + y + y + y
  389. (-1,-----------------------------------------------------------------------,
  390. 2
  391. y *(x + y + 1)
  392. 2 2 2 3
  393. - x *y + x - 2*x*y + x*y + x - y
  394. --------------------------------------),
  395. y*(x + y + 1)
  396. - x - y + 1 x + y
  397. (-1,--------------,-----------))
  398. x + y + 1 x + y + 1
  399. }
  400. test(answer,A);
  401. Seems O.K.
  402. %
  403. % Extend algebraic field to include sqrt(2).
  404. %
  405. % load_package arnum;
  406. defpoly sqrt2**2-2;
  407. A:= mat((4*sqrt2-6,-4*sqrt2+7,-3*sqrt2+6),(3*sqrt2-6,-3*sqrt2+7,
  408. -3*sqrt2+6),(3*sqrt2,1-3sqrt2,-2*sqrt2));
  409. [4*sqrt2 - 6 - (4*sqrt2 - 7) - (3*sqrt2 - 6)]
  410. [ ]
  411. a := [3*sqrt2 - 6 - (3*sqrt2 - 7) - (3*sqrt2 - 6)]
  412. [ ]
  413. [ 3*sqrt2 - (3*sqrt2 - 1) - 2*sqrt2 ]
  414. answer := ratjordan(A);
  415. answer := {
  416. [sqrt2 0 0 ]
  417. [ ]
  418. [ 0 sqrt2 0 ]
  419. [ ]
  420. [ 0 0 - (3*sqrt2 - 1)]
  421. ,
  422. [ 21 49 21 18 ]
  423. [7*sqrt2 - 6 ----*sqrt2 - ---- - (----*sqrt2 - ----)]
  424. [ 31 31 31 31 ]
  425. [ ]
  426. [ 21 18 21 18 ]
  427. [3*sqrt2 - 6 ----*sqrt2 - ---- - (----*sqrt2 - ----)]
  428. [ 31 31 31 31 ]
  429. [ ]
  430. [ 3 24 3 24 ]
  431. [3*sqrt2 + 1 - (----*sqrt2 + ----) ----*sqrt2 + ---- ]
  432. [ 31 31 31 31 ]
  433. ,
  434. [0 sqrt2 + 1 1 ]
  435. [ ]
  436. [-1 4*sqrt2 + 9 4*sqrt2]
  437. [ ]
  438. [ 1 ]
  439. [-1 - (---*sqrt2 - 1) 1 ]
  440. [ 6 ]
  441. }
  442. test(answer,A);
  443. Seems O.K.
  444. off arnum;
  445. A := mat((-12752,-6285,-9457,-7065,-4939,-5865,-3769),(13028,6430,
  446. 9656, 7213,5041,5984,3841),(16425,8080,12192,9108,6370,7569,
  447. 4871), (-6065,-2979,-4508,-3364,-2354,-2801,-1803),(2968,
  448. 1424,2231, 1664,1171,1404,919),(-22762,-11189,-16902,-12627,
  449. -8833, -10498,-6760),(23112,11400,17135,12799,8946,10622,
  450. 6821));
  451. [-12752 -6285 -9457 -7065 -4939 -5865 -3769]
  452. [ ]
  453. [13028 6430 9656 7213 5041 5984 3841 ]
  454. [ ]
  455. [16425 8080 12192 9108 6370 7569 4871 ]
  456. [ ]
  457. a := [-6065 -2979 -4508 -3364 -2354 -2801 -1803]
  458. [ ]
  459. [ 2968 1424 2231 1664 1171 1404 919 ]
  460. [ ]
  461. [-22762 -11189 -16902 -12627 -8833 -10498 -6760]
  462. [ ]
  463. [23112 11400 17135 12799 8946 10622 6821 ]
  464. R := first ratjordan(A);
  465. [0 2 0 0 0 0 0 ]
  466. [ ]
  467. [1 0 0 0 0 0 0 ]
  468. [ ]
  469. [0 0 0 0 0 0 5 ]
  470. [ ]
  471. r := [0 0 1 0 0 0 0 ]
  472. [ ]
  473. [0 0 0 1 0 0 -2]
  474. [ ]
  475. [0 0 0 0 1 0 3 ]
  476. [ ]
  477. [0 0 0 0 0 1 0 ]
  478. %
  479. % Calculate in Z/23Z...
  480. %
  481. on modular;
  482. setmod 23;
  483. 23
  484. R_mod := first ratjordan(A);
  485. [19 0 0 0 0 0 0 ]
  486. [ ]
  487. [0 18 0 0 0 0 0 ]
  488. [ ]
  489. [0 0 17 0 0 0 0 ]
  490. [ ]
  491. r_mod := [0 0 0 5 0 0 0 ]
  492. [ ]
  493. [0 0 0 0 0 0 5 ]
  494. [ ]
  495. [0 0 0 0 1 0 19]
  496. [ ]
  497. [0 0 0 0 0 1 10]
  498. %
  499. % ...and with a balanced modular representation.
  500. %
  501. on balanced_mod;
  502. R_bal_mod := first ratjordan(A);
  503. [5 0 0 0 0 0 0 ]
  504. [ ]
  505. [0 - 4 0 0 0 0 0 ]
  506. [ ]
  507. [0 0 - 5 0 0 0 0 ]
  508. [ ]
  509. r_bal_mod := [0 0 0 - 6 0 0 0 ]
  510. [ ]
  511. [0 0 0 0 0 0 5 ]
  512. [ ]
  513. [0 0 0 0 1 0 - 4]
  514. [ ]
  515. [0 0 0 0 0 1 10 ]
  516. off balanced_mod;
  517. off modular;
  518. %%%%%%%%%%%%%%%%%%%%%%%%%%% jordansymbolic %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  519. A := mat(((y+y^2-x^2)/y,(x-x^2-y+y^2)/y,(x^2-y^2)/y),(1+x+y,
  520. (x-y+y^2+x*y)/y,-x-y),((y-x+y^2-x^2)/y,(x-y+y^2-x^2)/y,
  521. (x+x^2-y^2)/y));
  522. [ 2 2 2 2 2 2 ]
  523. [ - x + y + y - x + x + y - y x - y ]
  524. [ ---------------- -------------------- --------- ]
  525. [ y y y ]
  526. [ ]
  527. [ 2 ]
  528. [ x*y + x + y - y ]
  529. a := [ x + y + 1 ------------------ - (x + y) ]
  530. [ y ]
  531. [ ]
  532. [ 2 2 2 2 2 2 ]
  533. [ - x - x + y + y - x + x + y - y x + x - y ]
  534. [-------------------- -------------------- -------------]
  535. [ y y y ]
  536. answer := jordansymbolic(A);
  537. answer := {
  538. [ x ]
  539. [--- 0 0 ]
  540. [ y ]
  541. [ ]
  542. [ x ]
  543. [ 0 --- 0 ]
  544. [ y ]
  545. [ ]
  546. [ 0 0 x + y]
  547. ,
  548. lambda*y - x
  549. {{--------------,lambda - x - y},
  550. y
  551. lambda},
  552. 3 2 2 2 2 2
  553. - x - 2*x *y - x - x*y + x*y + 2*y + y - x - x*y + y
  554. mat((---------------------------------------------,-----------------,
  555. y*(x + y + 1) 2
  556. x*y - x + y
  557. 2 2
  558. x + x - y - y
  559. -----------------),
  560. 2
  561. x*y - x + y
  562. y*(x + y + 1) - y*(x + y + 1)
  563. (x + y + 1,---------------,------------------),
  564. 2 2
  565. x*y - x + y x*y - x + y
  566. 2 2 2 2 2 2
  567. - x - x + y + 2*y - x - x + y + y x + x - y - y
  568. (----------------------,--------------------,-----------------))
  569. y 2 2
  570. x*y - x + y x*y - x + y
  571. ,
  572. x - y
  573. mat((0,-------,1),
  574. y
  575. 3 3 2 2 2 2 3 2 4 3 2
  576. - x *y + x - x *y - x *y + x + x*y - x*y - 2*x*y + y + y + y
  577. (-1,-----------------------------------------------------------------------,
  578. 2
  579. y *(x + y + 1)
  580. 2 2 2 3
  581. - x *y + x - 2*x*y + x*y + x - y
  582. --------------------------------------),
  583. y*(x + y + 1)
  584. - x - y + 1 x + y
  585. (-1,--------------,-----------))
  586. x + y + 1 x + y + 1
  587. }
  588. %
  589. % Extend algebraic field.
  590. %
  591. % load_package arnum;
  592. defpoly b^3-2*b+b-5;
  593. A := mat((1-b,2+b^2),(3+b-2*b^2,3));
  594. [ 2 ]
  595. [ - (b - 1) b + 2]
  596. a := [ ]
  597. [ 2 ]
  598. [ - (2*b - b - 3) 3 ]
  599. answer := jordansymbolic(A);
  600. answer := {
  601. [lambda11 0 ]
  602. [ ]
  603. [ 0 lambda12]
  604. ,
  605. 2 2
  606. {{lambda + (b - 4)*lambda + 3*b + 4*b - 8},lambda},
  607. [ lambda11 - 3 lambda12 - 3 ]
  608. [ ]
  609. [ 2 2 ]
  610. [ - (2*b - b - 3) - (2*b - b - 3)]
  611. ,
  612. 1966 2 3514 1054 1
  613. mat(( - (--------*b + --------*b - --------)*(lambda11 + ---*b - 2),
  614. 239891 239891 239891 2
  615. 127472 2 236383 82923
  616. (----------*b + ----------*b + ---------)
  617. 29986375 29986375 5997275
  618. 26 2 107 45
  619. *(lambda11 + ----*b - -----*b + ----)),
  620. 11 11 11
  621. 1966 2 3514 1054 1
  622. ( - (--------*b + --------*b - --------)*(lambda12 + ---*b - 2),
  623. 239891 239891 239891 2
  624. 127472 2 236383 82923
  625. (----------*b + ----------*b + ---------)
  626. 29986375 29986375 5997275
  627. 26 2 107 45
  628. *(lambda12 + ----*b - -----*b + ----)))
  629. 11 11 11
  630. }
  631. off arnum;
  632. A := mat((-9,21,-15,4,2,0),(-10,21,-14,4,2,0),(-8,16,-11,4,2,0),
  633. (-6,12,-9,3,3,0),(-4,8,-6,0,5,0),(-2,4,-3,0,1,3));
  634. [-9 21 -15 4 2 0]
  635. [ ]
  636. [-10 21 -14 4 2 0]
  637. [ ]
  638. [-8 16 -11 4 2 0]
  639. a := [ ]
  640. [-6 12 -9 3 3 0]
  641. [ ]
  642. [-4 8 -6 0 5 0]
  643. [ ]
  644. [-2 4 -3 0 1 3]
  645. answer := jordansymbolic(A);
  646. answer := {
  647. [3 0 0 0 0 0 ]
  648. [ ]
  649. [0 3 0 0 0 0 ]
  650. [ ]
  651. [0 0 1 1 0 0 ]
  652. [ ]
  653. [0 0 0 1 0 0 ]
  654. [ ]
  655. [0 0 0 0 lambda31 0 ]
  656. [ ]
  657. [0 0 0 0 0 lambda32]
  658. ,
  659. 2
  660. {{lambda - 3,lambda - 1,lambda - 4*lambda + 5},lambda},
  661. [ - 3 1 6*lambda31 - 17 6*lambda32 - 17 ]
  662. [3 ------ 1 --- ----------------- ----------------- ]
  663. [ 8 4 2 2 ]
  664. [ ]
  665. [ - 3 1 5*(lambda31 - 3) 5*(lambda32 - 3) ]
  666. [3 ------ 1 --- ------------------ ------------------]
  667. [ 8 4 2 2 ]
  668. [ ]
  669. [ - 3 1 ]
  670. [3 ------ 1 --- 2*(lambda31 - 3) 2*(lambda32 - 3) ]
  671. [ 8 4 ]
  672. [ ]
  673. [ - 3 3 3 3*(lambda31 - 3) 3*(lambda32 - 3) ]
  674. [3 ------ --- --- ------------------ ------------------]
  675. [ 8 4 8 2 2 ]
  676. [ ]
  677. [ - 3 1 1 ]
  678. [3 ------ --- --- lambda31 - 3 lambda32 - 3 ]
  679. [ 8 2 4 ]
  680. [ ]
  681. [ - 1 1 1 lambda31 - 3 lambda32 - 3 ]
  682. [2 ------ --- --- -------------- -------------- ]
  683. [ 8 4 8 2 2 ]
  684. ,
  685. [ - 1 ]
  686. [ 0 0 0 ------ 0 1]
  687. [ 3 ]
  688. [ ]
  689. [ 8 ]
  690. [ 0 0 0 --- -8 8]
  691. [ 3 ]
  692. [ ]
  693. [ 0 -4 6 0 -2 0]
  694. [ ]
  695. [ 0 0 -4 8 -4 0]
  696. [ ]
  697. [ - lambda31 + 3 lambda31 - 4 1 0 0 0]
  698. [ ]
  699. [ - lambda32 + 3 lambda32 - 4 1 0 0 0]
  700. }
  701. % Check to see if looking_good (*) is on as the choice of using
  702. % either lambda or xi is dependent upon this.
  703. % (* -> the use of looking_good is described in the manual.).
  704. if not lisp !*looking_good then
  705. <<
  706. %
  707. % NB: we use lambda_ in solve (instead of lambda) as lambda is used
  708. % for other purposes in REDUCE which mean it cannot be used with
  709. % solve.
  710. %
  711. solve(lambda_^2-4*lambda_+5,lambda_);
  712. J := sub({lambda31=i + 2,lambda32= - i + 2},first answer);
  713. P := sub({lambda31=i + 2,lambda32= - i + 2},third answer);
  714. Pinv :=sub({lambda31=i + 2,lambda32= - i + 2},third rest answer);
  715. >>
  716. else
  717. <<
  718. solve(xi^2-4*xi+5,xi);
  719. J := sub({xi(3,1)=i + 2,xi(3,2)= - i + 2},first answer);
  720. P := sub({xi(3,1)=i + 2,xi(3,2)= - i + 2},third answer);
  721. Pinv := sub({xi(3,1)=i + 2,xi(3,2)= - i + 2},third rest answer);
  722. >>;
  723. test({J,P,Pinv},A);
  724. Seems O.K.
  725. %
  726. % Calculate in Z/23Z...
  727. %
  728. on modular;
  729. setmod 23;
  730. 23
  731. answer := jordansymbolic(A)$
  732. J_mod := {first answer, second answer};
  733. j_mod := {
  734. [3 0 0 0 0 0 ]
  735. [ ]
  736. [0 3 0 0 0 0 ]
  737. [ ]
  738. [0 0 1 1 0 0 ]
  739. [ ]
  740. [0 0 0 1 0 0 ]
  741. [ ]
  742. [0 0 0 0 lambda31 0 ]
  743. [ ]
  744. [0 0 0 0 0 lambda32]
  745. ,
  746. 2
  747. {{lambda + 20,lambda + 22,lambda + 19*lambda + 5},lambda}}
  748. %
  749. % ...and with a balanced modular representation.
  750. %
  751. on balanced_mod;
  752. answer := jordansymbolic(A)$
  753. J_bal_mod := {first answer, second answer};
  754. j_bal_mod := {
  755. [3 0 0 0 0 0 ]
  756. [ ]
  757. [0 3 0 0 0 0 ]
  758. [ ]
  759. [0 0 1 1 0 0 ]
  760. [ ]
  761. [0 0 0 1 0 0 ]
  762. [ ]
  763. [0 0 0 0 lambda31 0 ]
  764. [ ]
  765. [0 0 0 0 0 lambda32]
  766. ,
  767. 2
  768. {{lambda - 3,lambda - 1,lambda - 4*lambda + 5},lambda}}
  769. off balanced_mod;
  770. off modular;
  771. %%%%%%%%%%%%%%%%%%%%%%%%%%%% jordan %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  772. A := mat((1,y),(y^2,3));
  773. [1 y]
  774. [ ]
  775. a := [ 2 ]
  776. [y 3]
  777. answer := jordan(A);
  778. answer := {
  779. [ 3 ]
  780. [sqrt(y + 1) + 2 0 ]
  781. [ ]
  782. [ 3 ]
  783. [ 0 - sqrt(y + 1) + 2]
  784. ,
  785. [ 3 3 ]
  786. [sqrt(y + 1) - 1 - (sqrt(y + 1) + 1)]
  787. [ ]
  788. [ 2 2 ]
  789. [ y y ]
  790. ,
  791. [ 3 3 3 ]
  792. [ sqrt(y + 1) sqrt(y + 1) + y + 1 ]
  793. [ -------------- ----------------------- ]
  794. [ 3 2 3 ]
  795. [ 2*(y + 1) 2*y *(y + 1) ]
  796. [ ]
  797. [ 3 3 3 ]
  798. [ - sqrt(y + 1) - sqrt(y + 1) + y + 1 ]
  799. [----------------- --------------------------]
  800. [ 3 2 3 ]
  801. [ 2*(y + 1) 2*y *(y + 1) ]
  802. }
  803. test(answer,A);
  804. Seems O.K.
  805. A := mat((-12752,-6285,-9457,-7065,-4939,-5865,-3769),(13028,6430,
  806. 9656, 7213,5041,5984,3841),(16425,8080,12192,9108,6370,7569,
  807. 4871), (-6065,-2979,-4508,-3364,-2354,-2801,-1803),(2968,
  808. 1424,2231, 1664,1171,1404,919),(-22762,-11189,-16902,-12627,
  809. -8833, -10498,-6760),(23112,11400,17135,12799,8946,10622,
  810. 6821));
  811. [-12752 -6285 -9457 -7065 -4939 -5865 -3769]
  812. [ ]
  813. [13028 6430 9656 7213 5041 5984 3841 ]
  814. [ ]
  815. [16425 8080 12192 9108 6370 7569 4871 ]
  816. [ ]
  817. a := [-6065 -2979 -4508 -3364 -2354 -2801 -1803]
  818. [ ]
  819. [ 2968 1424 2231 1664 1171 1404 919 ]
  820. [ ]
  821. [-22762 -11189 -16902 -12627 -8833 -10498 -6760]
  822. [ ]
  823. [23112 11400 17135 12799 8946 10622 6821 ]
  824. on rounded;
  825. J := first jordan(A);
  826. *** Domain mode rounded changed to rational
  827. *** Domain mode rational changed to complex-rational
  828. *** Domain mode complex-rational changed to rational
  829. *** Domain mode rational changed to rounded
  830. j := mat((1.41421356237,0,0,0,0,0,0),
  831. (0, - 1.41421356237,0,0,0,0,0),
  832. (0,0, - 1.80492,0,0,0,0),
  833. (0,0,0, - 1.12491,0,0,0),
  834. (0,0,0,0,1.03589*i + 0.620319,0,0),
  835. (0,0,0,0,0, - 1.03589*i + 0.620319,0),
  836. (0,0,0,0,0,0,1.68919))
  837. off rounded;
  838. %
  839. % Extend algebraic field.
  840. %
  841. % load_package arnum;
  842. defpoly b^3-2*b+b-5;
  843. A := mat((1-b,2+b^2),(3+b-2*b^2,3));
  844. [ 2 ]
  845. [ - (b - 1) b + 2]
  846. a := [ ]
  847. [ 2 ]
  848. [ - (2*b - b - 3) 3 ]
  849. J := first jordan(A);
  850. 1 2
  851. j := mat((---*(sqrt(11*b + 24*b - 48)*i - (b - 4)),0),
  852. 2
  853. 1 2
  854. (0, - ---*(sqrt(11*b + 24*b - 48)*i + b - 4)))
  855. 2
  856. off arnum;
  857. end;
  858. Time for test: 1919 ms, plus GC time: 109 ms