cantens.rlg 21 KB

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