cantens.rlg 21 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939
  1. Tue Jan 5 22:09:49 MET 1999
  2. REDUCE 3.7, 15-Jan-99 ...
  3. 1: 1:
  4. 2: 2: 2: 2: 2: 2: 2: 2: 2:
  5. 3: 3: % Test of CANTENS.RED
  6. %
  7. % Authors: H. Caprasse <hubert.caprasse@ulg.ac.be>
  8. %
  9. % Version and Date: Version 1.1, 15 September 1998.
  10. %----------------------------------------------------------------
  11. off errcont;
  12. % Default :
  13. onespace ?;
  14. yes
  15. wholespace_dim ?;
  16. dim
  17. global_sign ? ;
  18. 1
  19. signature ?;
  20. 0
  21. % answers to the 4 previous commands: yes, dim, 1, 0
  22. wholespace_dim 4;
  23. 4
  24. signature 1;
  25. 1
  26. global_sign(-1);
  27. -1
  28. % answers to the three previous commands: 4, 1, (-1)
  29. % answer to the command below: {}
  30. show_spaces();
  31. {}
  32. % Several spaces:
  33. off onespace;
  34. onespace ?;
  35. no
  36. % answer: no
  37. show_spaces();
  38. {}
  39. define_spaces wholespace={6,signature=1,indexrange=0 .. 5};
  40. t
  41. % indexrange command is superfluous since 'wholespace':
  42. show_spaces();
  43. {{wholespace,6,signature=1,indexrange=0 .. 5}}
  44. rem_spaces wholespace;
  45. t
  46. define_spaces wholespace={11,signature=1};
  47. t
  48. define_spaces mink={4,signature=1,indexrange=0 .. 3};
  49. t
  50. define_spaces eucl={6,euclidian,indexrange=4 .. 9};
  51. t
  52. show_spaces();
  53. {{wholespace,11,signature=1},
  54. {mink,4,signature=1,indexrange=0 .. 3},
  55. {eucl,6,euclidian,indexrange=4 .. 9}}
  56. %
  57. % if input error or modifications necessary:
  58. %
  59. define_spaces eucl={7,euclidian,indexrange=4 .. 10};
  60. *** Warning: eucl cannot be (or is already) defined as space identifier
  61. t
  62. %
  63. % do:
  64. %
  65. rem_spaces eucl;
  66. t
  67. define_spaces eucl={7,euclidian,indexrange=4 .. 10};
  68. t
  69. show_spaces();
  70. {{wholespace,11,signature=1},
  71. {mink,4,signature=1,indexrange=0 .. 3},
  72. {eucl,7,euclidian,indexrange=4 .. 10}}
  73. % done
  74. %
  75. define_spaces eucl1={1,euclidian,indexrange=11 .. 11};
  76. t
  77. show_spaces();
  78. {{wholespace,11,signature=1},
  79. {mink,4,signature=1,indexrange=0 .. 3},
  80. {eucl,7,euclidian,indexrange=4 .. 10},
  81. {eucl1,1,euclidian,indexrange=11 .. 11}}
  82. rem_spaces wholespace,mink,eucl,eucl1;
  83. t
  84. show_spaces();
  85. {}
  86. %
  87. % Indices can be made to belong to a subspace or replaced
  88. % in the whole space:
  89. define_spaces eucl={3,euclidean};
  90. t
  91. show_spaces();
  92. {{eucl,3,euclidean}}
  93. mk_ids_belong_space({a1,a2},eucl);
  94. t
  95. % a1,a2 belong to the subspace eucl.
  96. mk_ids_belong_anyspace a1,a2;
  97. t
  98. % replaced in the whole space.
  99. rem_spaces eucl;
  100. t
  101. %%
  102. %% GENERIC TENSORS:
  103. on onespace;
  104. wholespace_dim dim;
  105. dim
  106. tensor te;
  107. t
  108. te(3,a,-4,b,-c,7);
  109. 3 a b 7
  110. te
  111. 4 c
  112. te(3,a,{x,y},-4,b,-c,7);
  113. 3 a b 7
  114. te (x,y)
  115. 4 c
  116. te(3,a,-4,b,{u,v},-c,7);
  117. 3 a b 7
  118. te (u,v)
  119. 4 c
  120. te({x,y});
  121. te(x,y)
  122. make_variables x,y;
  123. t
  124. te(x,y);
  125. te(x,y)
  126. te(x,y,a);
  127. a
  128. te (x,y)
  129. remove_variables x;
  130. t
  131. te(x,y,a);
  132. x a
  133. te (y)
  134. remove_variables y;
  135. t
  136. %
  137. % implicit dependence:
  138. %
  139. operator op2;
  140. depend op1,op2(x);
  141. df(op1,op2(x));
  142. df(op1,op2(x))
  143. % the next response is 0:
  144. df(op1,op2(y));
  145. 0
  146. clear op2;
  147. % case of a tensor:
  148. operator op1;
  149. depend te,op1(x);
  150. df(te(a,-b),op1(x));
  151. a
  152. df(te ,op1(x))
  153. b
  154. % next the outcome is 0:
  155. df(te(a,-b),op1(y));
  156. 0
  157. %
  158. tensor x;
  159. t
  160. depend te,x;
  161. % outcome is NOT 0:
  162. df(te(a,-b),x(c));
  163. a c
  164. df(te ,x )
  165. b
  166. %
  167. % Substitutions:
  168. sub(a=-c,te(a,b));
  169. b
  170. te
  171. c
  172. sub(a=-1,te(a,b));
  173. b
  174. te
  175. 1
  176. % the following operation is wrong:
  177. sub(a=-0,te(a,b));
  178. 0 b
  179. te
  180. % should be made as following to be correct:
  181. sub(a=-!0,te(a,b));
  182. b
  183. te
  184. 0
  185. % dummy indices recognition
  186. dummy_indices();
  187. {}
  188. te(a,b,-c,-a);
  189. a b
  190. te
  191. c a
  192. dummy_indices();
  193. {a}
  194. te(a,b,-c,-a);
  195. a b
  196. te
  197. c a
  198. dummy_indices();
  199. {a}
  200. % hereunder an error message correctly occurs:
  201. on errcont;
  202. te(a,b,-c,a);
  203. ***** ((c) (a b a)) are inconsistent lists of indices
  204. off errcont;
  205. sub(c=b,te(a,b,-c,-a));
  206. a b
  207. te
  208. b a
  209. dummy_indices();
  210. {b,a}
  211. % dummy indices suppression:
  212. on errcont;
  213. te(d,-d,d);
  214. ***** ((d) (d d)) are inconsistent lists of indices
  215. off errcont;
  216. dummy_indices();
  217. {d,b,a}
  218. rem_dummy_indices d;
  219. t
  220. te(d,d);
  221. d d
  222. te
  223. dummy_indices();
  224. {b,a}
  225. rem_dummy_indices a,b;
  226. t
  227. onespace ?;
  228. yes
  229. % case of space of integer dimension:
  230. wholespace_dim 4;
  231. 4
  232. signature 0;
  233. 0
  234. % 7 out of range
  235. on errcont;
  236. te(3,a,-b,7);
  237. ***** numeric indices out of range
  238. off errcont;
  239. te(3,a,-b,3);
  240. 3 a 3
  241. te
  242. b
  243. te(4,a,-b,4);
  244. 4 a 4
  245. te
  246. b
  247. % an 'out-of-range' error is issued:
  248. on errcont;
  249. sub(a=5,te(3,a,-b,3));
  250. ***** numeric indices out of range
  251. off errcont;
  252. signature 1;
  253. 1
  254. % now indices should run from 0 to 3 => error:
  255. on errcont;
  256. te(4,a,-b,4);
  257. ***** numeric indices out of range
  258. off errcont;
  259. % correct:
  260. te(0,a,-b,3);
  261. 0 a 3
  262. te
  263. b
  264. %
  265. off onespace;
  266. define_spaces wholespace={4,euclidean};
  267. t
  268. % We MUST say that te BELONG TO A SPACE, here to wholespace:
  269. make_tensor_belong_space(te,wholespace);
  270. wholespace
  271. on errcont;
  272. te(a,5,-b);
  273. ***** numeric indices out of range
  274. off errcont;
  275. te(a,4,-b);
  276. a 4
  277. te
  278. b
  279. rem_spaces wholespace;
  280. t
  281. define_spaces wholespace={5,signature=1};
  282. t
  283. define_spaces eucl={1,signature=0};
  284. t
  285. show_spaces();
  286. {{wholespace,5,signature=1},
  287. {eucl,1,signature=0}}
  288. make_tensor_belong_space(te,eucl);
  289. eucl
  290. te(1);
  291. 1
  292. te
  293. % hereunder, an error message is issued:
  294. on errcont;
  295. te(2);
  296. ***** numeric indices out of range
  297. off errcont;
  298. % hereunder, an error message should be issued, it is not
  299. % because no indexrange has been declared:
  300. te(0);
  301. 0
  302. te
  303. rem_spaces eucl;
  304. t
  305. define_spaces eucl={1,signature=0,indexrange=1 .. 1};
  306. t
  307. % NOW an error message is issued:
  308. on errcont;
  309. te(0);
  310. ***** numeric indices do not belong to (sub)-space
  311. off errcont;
  312. te(1);
  313. 1
  314. te
  315. % again an error message:
  316. on errcont;
  317. te(2);
  318. ***** numeric indices do not belong to (sub)-space
  319. off errcont;
  320. %
  321. rem_dummy_indices a,b,c,d;
  322. t
  323. % symmetry properties:
  324. %
  325. symmetric te;
  326. te(a,-b,c,d);
  327. a c d
  328. te
  329. b
  330. remsym te;
  331. antisymmetric te;
  332. te(a,b,-c,d);
  333. a b d
  334. - te
  335. c
  336. remsym te;
  337. % mixed symmetries:
  338. tensor r;
  339. t
  340. %
  341. symtree(r,{!+,{!-,1,2},{!-,3,4}});
  342. ra:=r(b,a,c,d)$
  343. canonical ra;
  344. a b c d
  345. - r
  346. ra:=r(c,d,a,b)$
  347. canonical ra;
  348. a b c d
  349. r
  350. % here canonical is short-cutted
  351. ra:=r(b,b,c,a);
  352. ra := 0
  353. %
  354. % symmetrization:
  355. on onespace;
  356. symmetrize(r(a,b,c,d),r,permutations,perm_sign);
  357. a b c d a b d c a c b d a c d b a d b c a d c b b a c d
  358. r - r - r + r + r - r - r
  359. b a d c b c a d b c d a b d a c b d c a c a b d c a d b
  360. + r + r - r - r + r + r - r
  361. c b a d c b d a c d a b c d b a d a b c d a c b d b a c
  362. - r + r + r - r - r + r + r
  363. d b c a d c a b d c b a
  364. - r - r + r
  365. canonical ws;
  366. a b c d a c b d a d b c
  367. 8*(r - r + r )
  368. off onespace;
  369. symmetrize({a,b,c,d},r,cyclicpermlist);
  370. a b c d b c d a c d a b d a b c
  371. r + r + r + r
  372. canonical ws;
  373. a b c d a d b c
  374. 2*(r - r )
  375. rem_tensor r;
  376. t
  377. % Declared bloc-diagonal tensor:
  378. rem_spaces wholespace,eucl;
  379. t
  380. define_spaces wholespace={7,signature=1};
  381. t
  382. define_spaces mink={4,signature=1,indexrange=0 .. 3};
  383. t
  384. define_spaces eucl={3,euclidian,indexrange=4 .. 6};
  385. t
  386. show_spaces();
  387. {{wholespace,7,signature=1},
  388. {mink,4,signature=1,indexrange=0 .. 3},
  389. {eucl,3,euclidian,indexrange=4 .. 6}}
  390. make_tensor_belong_space(te,eucl);
  391. eucl
  392. make_bloc_diagonal te;
  393. t
  394. mk_ids_belong_space({a,b,c},eucl);
  395. t
  396. te(a,b,z);
  397. a b z
  398. te
  399. mk_ids_belong_space({m1,m2},mink);
  400. t
  401. te(a,b,m1);
  402. 0
  403. te(a,b,m2);
  404. 0
  405. mk_ids_belong_anyspace a,b,c,m1,m2;
  406. t
  407. te(a,b,m2);
  408. a b m2
  409. te
  410. % how to ASSIGN a particular component ?
  411. % take the simplest context:
  412. rem_spaces wholespace,mink,eucl;
  413. t
  414. on onespace;
  415. te({x,y},a,-0)==x*y*te(a,-0);
  416. a
  417. te *x*y
  418. 0
  419. te({x,y},a,-0);
  420. a
  421. te *x*y
  422. 0
  423. te({x,y},a,0);
  424. a 0
  425. te (x,y)
  426. % hereunder an error message is issued because already assigned:
  427. on errcont;
  428. te({x,y},a,-0)==x*y*te(a,-0);
  429. a
  430. ***** te *x*y invalid as setvalue kernel
  431. 0
  432. off errcont;
  433. % clear value:
  434. rem_value_tens te({x,y},a,-0);
  435. t
  436. te({x,y},a,-0);
  437. a
  438. te (x,y)
  439. 0
  440. te({x,y},a,-0)==(x+y)*te(a,-0);
  441. a
  442. te *(x + y)
  443. 0
  444. % A small illustration
  445. te(1)==sin th * cos phi;
  446. cos(phi)*sin(th)
  447. te(-1)==sin th * cos phi;
  448. cos(phi)*sin(th)
  449. te(2)==sin th * sin phi;
  450. sin(phi)*sin(th)
  451. te(-2)==sin th * sin phi;
  452. sin(phi)*sin(th)
  453. te(3)==cos th ;
  454. cos(th)
  455. te(-3)==cos th ;
  456. cos(th)
  457. for i:=1:3 sum te(i)*te(-i);
  458. 2 2 2 2 2
  459. cos(phi) *sin(th) + cos(th) + sin(phi) *sin(th)
  460. rem_value_tens te;
  461. t
  462. te(2);
  463. 2
  464. te
  465. let te({x,y},-0)=x*y;
  466. te({x,y},-0);
  467. x*y
  468. te({x,y},0);
  469. 0
  470. te (x,y)
  471. te({x,u},-0);
  472. te (x,u)
  473. 0
  474. for all x,a let te({x},a,-b)=x*te(a,-b);
  475. te({u},1,-b);
  476. 1
  477. te *u
  478. b
  479. te({u},c,-b);
  480. c
  481. te *u
  482. b
  483. te({u},b,-b);
  484. b
  485. te *u
  486. b
  487. te({u},a,-a);
  488. a
  489. te (u)
  490. a
  491. for all x,a clear te({x},a,-b);
  492. te({u},c,-b);
  493. c
  494. te (u)
  495. b
  496. % rule for indices only
  497. for all a,b let te({x},a,-b)=x*te(a,-b);
  498. te({x},c,-b);
  499. c
  500. te *x
  501. b
  502. te({x},a,-a);
  503. a
  504. te *x
  505. a
  506. % A BUG still exists for -0 i.e. rule does NOT apply:
  507. te({x},a,-0);
  508. a
  509. te (x)
  510. 0
  511. % the cure is to use -!0 in this case
  512. te({x},0,-!0);
  513. 0
  514. te *x
  515. 0
  516. %
  517. % local rules:
  518. %
  519. rul:={te(~a) => sin a};
  520. ~a
  521. rul := {te => sin(a)}
  522. te(1) where rul;
  523. sin(1)
  524. %
  525. rul1:={te(~a,{~x,~y}) => x*y*sin(a)};
  526. ~a
  527. rul1 := {te (~x,~y) => x*y*sin(a)}
  528. %
  529. te(a,{x,y}) where rul1;
  530. sin(a)*x*y
  531. te({x,y},a) where rul1;
  532. sin(a)*x*y
  533. %
  534. rul2:={te(-~a,{~x,~y}) => x*y*sin(-a)};
  535. rul2 := {te (~x,~y) => x*y*sin( - a)}
  536. ~a
  537. %
  538. te(-a,{x,y}) where rul2;
  539. - sin(a)*x*y
  540. te({x,y},-a) where rul2;
  541. - sin(a)*x*y
  542. %% CANONICAL
  543. %
  544. % 1. Coherence of tensorial indices.
  545. %
  546. tensor te,tf;
  547. *** Warning: te redefined as generic tensor
  548. t
  549. dummy_indices();
  550. {a,b}
  551. make_tensor_belong_anyspace te;
  552. t
  553. on errcont;
  554. bb:=te(a,b)*te(-b)*te(b);
  555. a b b
  556. bb := te *te *te
  557. b
  558. % hereunder an error message is issued:
  559. canonical bb;
  560. ***** ((b) (a b b)) are inconsistent lists of indices
  561. off errcont;
  562. bb:=te(a,b)*te(-b);
  563. a b
  564. bb := te *te
  565. b
  566. % notice how it is rewritten by canonical:
  567. canonical bb;
  568. a b
  569. te *te
  570. b
  571. %
  572. dummy_indices();
  573. {a,b}
  574. aa:=te(d,-c)*tf(d,-c);
  575. d d
  576. aa := te *tf
  577. c c
  578. % if a and c are FREE no error message:
  579. canonical aa;
  580. d d
  581. te *tf
  582. c c
  583. % do NOT introduce powers for NON-INVARIANT tensors:
  584. aa:=te(d,-c)*te(d,-c);
  585. d 2
  586. aa := (te )
  587. c
  588. % Powers are taken away
  589. canonical aa;
  590. d
  591. te
  592. c
  593. % A trace CANNOT be squared because powers are removed by 'canonical':
  594. cc:=te(a,-a)^2$
  595. canonical cc;
  596. a
  597. te
  598. a
  599. %
  600. % Correct writing of the previous squared:
  601. cc:=te(a,-a)*te(b,-b)$
  602. canonical cc;
  603. a b
  604. te *te
  605. a b
  606. % all terms must have the same variance:
  607. on errcont;
  608. aa:=te(a,c)+x^2;
  609. a c 2
  610. aa := te + x
  611. canonical aa;
  612. ***** scalar added with tensor(s)
  613. aa:=te(a,b)+tf(a,c);
  614. a b a c
  615. aa := te + tf
  616. canonical aa;
  617. ***** mismatch in free indices : ((a c) (a b))
  618. off errcont;
  619. dummy_indices();
  620. {a,b}
  621. rem_dummy_indices a,b,c;
  622. t
  623. dummy_indices();
  624. {}
  625. % a dummy VARIABLE is NOT a dummy INDEX
  626. dummy_names b;
  627. t
  628. dummy_indices();
  629. {}
  630. % so, no error message in the following:
  631. canonical(te(b,c)*tf(b,c));
  632. b c b c
  633. te *tf
  634. % it is an incorrect input for a variable.
  635. % correct input is:
  636. canonical(te({b},c)*tf({b},c));
  637. c c
  638. te (b)*tf (b)
  639. clear_dummy_names;
  640. t
  641. % contravariant indices are placed before covariant ones if possible.
  642. % i.e. Riemanian spaces by default:
  643. pp:=te(a,-a)+te(-a,a)+1;
  644. a a
  645. pp := te + te + 1
  646. a a
  647. canonical pp;
  648. a
  649. 2*te + 1
  650. a
  651. pp:=te(a,-c)+te(-b,b,a,-c);
  652. b a a
  653. pp := te + te
  654. b c c
  655. canonical pp;
  656. a b a
  657. te + te
  658. c b c
  659. pp:=te(r,a,-f,d,-a,f)+te(r,-b,-c,d,b,c);
  660. r d b c r a d f
  661. pp := te + te
  662. b c f a
  663. canonical pp;
  664. r a b d
  665. 2*te
  666. a b
  667. % here, a case where a normal form cannot be obtained:
  668. tensor nt;
  669. t
  670. a1:=nt(-a,d)*nt(-c,a);
  671. d a
  672. a1 := nt *nt
  673. a c
  674. a2:=nt(-c,-a)*nt(a,d);
  675. a d
  676. a2 := nt *nt
  677. c a
  678. % obviously, a1-a2 =0, but ....
  679. canonical(a1-a2);
  680. d a a d
  681. - nt *nt + nt *nt
  682. a c c a
  683. % does give the same expression with the sign changed.
  684. % zero is either:
  685. canonical a1 -a2;
  686. 0
  687. % or
  688. a1 -canonical a2;
  689. 0
  690. % below the result is a2:
  691. canonical a1;
  692. a d
  693. nt *nt
  694. c a
  695. % below result is a1 again:
  696. canonical ws;
  697. d a
  698. nt *nt
  699. a c
  700. % the above manipulations are NOT DONE if space is AFFINE
  701. off onespace;
  702. define_spaces aff={dd,affine};
  703. t
  704. make_tensor_belong_space(te,aff);
  705. aff
  706. % dummy indices MUST be declared to belong
  707. % to a well defined space. here to 'aff':
  708. mk_ids_belong_space({a,b},aff);
  709. t
  710. canonical(te(-a,a));
  711. a
  712. te
  713. a
  714. canonical(te(-a,a)+te(b,-b));
  715. a a
  716. te + te
  717. a a
  718. canonical(te(-a,c));
  719. c
  720. te
  721. a
  722. % put back the system in the previous status:
  723. make_tensor_belong_anyspace te;
  724. t
  725. mk_ids_belong_anyspace a,b;
  726. t
  727. rem_spaces aff;
  728. t
  729. on onespace;
  730. %
  731. % 2. Summations with DELTA tensor.
  732. %
  733. make_partic_tens(delta,delta);
  734. t
  735. aa:=delta(a,-b)*delta(b,-c)*delta(c,-a) + 1;
  736. a b c
  737. aa := delta *delta *delta + 1
  738. b c a
  739. % below, answer is dim+1:
  740. canonical aa;
  741. dim + 1
  742. aa:=delta(a,-b)*delta(b,-c)*delta(c,-d)*te(d,e)$
  743. canonical aa;
  744. a e
  745. te
  746. % 3. Summations with DELTA and ETA tensors.
  747. make_partic_tens(eta,eta);
  748. t
  749. signature 1;
  750. 1
  751. aa:=eta(a,b)*eta(-b,-c);
  752. a b
  753. aa := eta *eta
  754. b c
  755. canonical aa;
  756. a
  757. delta
  758. c
  759. aa:=eta(a,b)*eta(-b,-c)*eta(c,d);
  760. a b c d
  761. aa := eta *eta *eta
  762. b c
  763. canonical aa;
  764. a d
  765. eta
  766. aa:=eta(a,b)*eta(-b,-c)*eta(d,c)*te(d,-a) +te(d,d);
  767. a b c d d d d
  768. aa := eta *eta *eta *te + te
  769. b c a
  770. canonical aa;
  771. d d
  772. 2*te
  773. aa:=delta(a,-b)*eta(b,c);
  774. a b c
  775. aa := delta *eta
  776. b
  777. canonical aa;
  778. a c
  779. eta
  780. aa:=delta(a,-b)*delta(d,-a)*eta(-c,-d)*eta(b,c);
  781. a d b c
  782. aa := delta *delta *eta *eta
  783. b a c d
  784. % below the answer is dim:
  785. canonical aa;
  786. dim
  787. aa:=delta(a,-b)*delta(d,-a)*eta(-d,-e)*te(f,g,e);
  788. a d f g e
  789. aa := delta *delta *eta *te
  790. b a d e
  791. canonical aa;
  792. f g
  793. te
  794. b
  795. % Summations with the addition of the METRIC tensor:
  796. make_partic_tens(g,metric);
  797. t
  798. g(1,2,{x})==1/4*sin x;
  799. sin(x)
  800. --------
  801. 4
  802. g({x},1,2);
  803. sin(x)
  804. --------
  805. 4
  806. aa:=g(a,b)*g(-a,-c);
  807. a b
  808. aa := g *g
  809. a c
  810. canonical aa;
  811. b
  812. delta
  813. c
  814. aa:=g(a,b)*g(c,d)*eta(-c,-b);
  815. a b c d
  816. aa := eta *g *g
  817. b c
  818. % answer is g(a,d):
  819. canonical aa;
  820. a d
  821. g
  822. tensor te;
  823. *** Warning: te redefined as generic tensor
  824. t
  825. aa:=g(a,b)*g(c,d)*eta(-c,-e)*eta(e,f)*te(-f,g);
  826. e f a b c d g
  827. aa := eta *eta *g *g *te
  828. c e f
  829. canonical aa;
  830. a b d g
  831. g *te
  832. % Summations with the addition of the EPSILON tensor.
  833. dummy_indices();
  834. {c,f,b,a}
  835. rem_dummy_indices a,b,c,f;
  836. t
  837. dummy_indices();
  838. {}
  839. wholespace_dim ?;
  840. dim
  841. signature ?;
  842. 1
  843. % define the generalized delta function:
  844. make_partic_tens(gd,del);
  845. t
  846. make_partic_tens(epsilon,epsilon);
  847. t
  848. aa:=epsilon(a,b)*epsilon(-c,-d);
  849. a b
  850. aa := epsilon *epsilon
  851. c d
  852. % Minus sign reflects the chosen signature.
  853. canonical aa;
  854. a b
  855. - gd
  856. c d
  857. aa:=epsilon(a,b)*epsilon(-a,-b);
  858. a b
  859. aa := epsilon *epsilon
  860. a b
  861. canonical aa;
  862. dim*( - dim + 1)
  863. aa:=epsilon(a,b,c,d)*epsilon(-a,-b,-c,-e);
  864. a b c d
  865. aa := epsilon *epsilon
  866. a b c e
  867. canonical aa;
  868. d 3 2
  869. delta *( - dim + 6*dim - 11*dim + 6)
  870. e
  871. on exdelt;
  872. % extract delta function down to the bottom:
  873. aa:=epsilon(a,b,c)*epsilon(-b,-d,-e);
  874. a b c
  875. aa := epsilon *epsilon
  876. b d e
  877. canonical aa;
  878. a c a c a c
  879. delta *delta *dim - 2*delta *delta - delta *delta *dim
  880. d e d e e d
  881. a c
  882. + 2*delta *delta
  883. e d
  884. off exdelt;
  885. % below expressed in terms of 'gd' tensor.
  886. canonical aa;
  887. a c
  888. gd *(dim - 2)
  889. d e
  890. rem_dummy_indices a;
  891. t
  892. aa:=epsilon(- b,-c)*eta(a,b)*eta(a,c);
  893. a b a c
  894. aa := epsilon *eta *eta
  895. b c
  896. % answer below is zero:
  897. canonical aa;
  898. 0
  899. aa:=epsilon(a,b,c)*te(-a)*te(-b);
  900. a b c
  901. aa := epsilon *te *te
  902. a b
  903. % below the result is again zero.
  904. canonical aa;
  905. 0
  906. %
  907. tensor tf,tg;
  908. *** Warning: tf redefined as generic tensor
  909. t
  910. aa:=epsilon(a,b,c)*te(-a)*tf(-b)*tg(-c)+epsilon(d,e,f)*te(-d)*tf(-e)*tg(-f);
  911. a b c d e f
  912. aa := epsilon *te *tf *tg + epsilon *te *tf *tg
  913. a b c d e f
  914. % below the result is twice the first term.
  915. canonical aa;
  916. a b c
  917. 2*epsilon *te *tf *tg
  918. a b c
  919. aa:=epsilon(a,b,c)*te(-a)*tf(-c)*tg(-b)+epsilon(d,e,f)*te(-d)*tf(-e)*tg(-f);
  920. a b c d e f
  921. aa := epsilon *te *tf *tg + epsilon *te *tf *tg
  922. a c b d e f
  923. % below the result is zero.
  924. canonical aa;
  925. 0
  926. % An illustration when working inside several spaces.
  927. rem_dummy_indices a,b,c,d,e,f;
  928. t
  929. off onespace;
  930. define_spaces wholespace={dim,signature=1};
  931. t
  932. define_spaces sub4={4,signature=1};
  933. t
  934. define_spaces subd={dim-4,signature=0};
  935. t
  936. show_spaces();
  937. {{wholespace,dim,signature=1},
  938. {sub4,4,signature=1},
  939. {subd,dim - 4,signature=0}}
  940. make_partic_tens(epsilon,epsilon);
  941. *** Warning: epsilon redefined as particular tensor
  942. t
  943. make_tensor_belong_space(epsilon,sub4);
  944. sub4
  945. make_partic_tens(kappa,epsilon);
  946. *** Warning: kappa MUST belong to a space
  947. t
  948. make_tensor_belong_space(kappa,subd);
  949. subd
  950. show_epsilons();
  951. {{kappa,subd},{epsilon,sub4}}
  952. mk_ids_belong_space({i,j,k,l,m,n,r,s},sub4);
  953. t
  954. mk_ids_belong_space({a,b,c,d,e,f},subd);
  955. t
  956. off exdelt;
  957. aa:=kappa(a,b,c)*kappa(-d,-e,-f)*epsilon(i,j,k,l)*epsilon(-k,-l,-i,-j);
  958. i j k l a b c
  959. aa := epsilon *epsilon *kappa *kappa
  960. i j k l d e f
  961. canonical aa;
  962. a b c
  963. - 24*gd
  964. d e f
  965. aa:=kappa(a,b,c)*kappa(-d,-e,-f)*epsilon(i,j,k,l)*epsilon(-m,-n,-r,-s);
  966. i j k l a b c
  967. aa := epsilon *epsilon *kappa *kappa
  968. m n r s d e f
  969. canonical aa;
  970. a b c i j k l
  971. - gd *gd
  972. d e f m n r s
  973. end;
  974. 4: 4: 4: 4: 4: 4: 4: 4: 4:
  975. Time for test: 320 ms
  976. 5: 5:
  977. Quitting
  978. Tue Jan 5 22:09:52 MET 1999