1 /* Copyright (C) 2003 Valerij Pipin <pip@iszf.irk.ru>
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be
9 * useful, but WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
14 * Simplification of expressions containing the Levi-Civita symbol.
17 lc2kdt(exp):=block([i1,tem],
19 if nterms(exp)=1 then _lc2kdt0(exp)
22 for i1 thru nterms(exp) do
23 tem:tem+_lc2kdt0(part(exp,i1)),
29 [exp:expand(exp),n:nterms(exp)],
30 sum(_lc2kdt0(if n>1 then part(exp,i%) else exp),i%,1,n)
34 _lc2kdt0(exp):=block([temp1:1,temp2:1,temp,i1],
35 if part(exp,0)="-" then for i1 thru length(part(num(exp),1)) do
37 temp:part(num(exp),1,i1),
38 if tenpr(temp) and verbify(name(temp))=levi_civita then
40 temp1:_lcprod(temp1,temp),
44 else for i1 thru length(num(exp)) do
46 temp:part(num(exp),i1),
47 if tenpr(temp) and verbify(name(temp))=levi_civita then
49 temp1:_lcprod(temp1,temp),
53 temp1*ratsimp(exp/temp2)
58 if op(exp)="-" then return(-_lc2kdt0(part(exp,1))),
59 if op(num(exp))#"*" then return(exp),
60 for i thru length(num(exp)) do
63 if tenpr(fac) and verbify(name(fac))=levi_civita then
67 ratsimp(res*fre)/denom(exp)
70 /*_lcprod(lc1,lc2):=block([temp1,tempk,ln11,lf,l1,l2,l11,l22,lku,lkl],
71 if numberp(lc1) or symbolp(lc1) then lc1*lc2
72 else if tenpr(lc2) then /* so name(LC1)=LC */
74 if verbify(name(lc2))=levi_civita and tenpr(lc1) then
75 ( /* again test if LC1 is a single */
85 ln11:makelist(idummy(),i,1,lf),
89 tempk:tempk*kdelta([],[ln11[i],l11[i]])
91 kdelta(ln11,l22)*tempk
96 ln11:makelist(idummy(),i,1,lf),
100 tempk:tempk*kdelta([l1[i],ln11[i]],[])
102 kdelta(l2,ln11)*tempk
110 if numberp(lc2) or symbolp(lc2) then lc2*lc1
113 temp1:_extlc(lc1,lc2),
114 _lcprod(lc1,temp1)*(lc2/temp1)
119 _lcprod(lc1,lc2):=block([temp1,ln11,lf,l1,l2,l11,l22,lku,lkl],
120 if numberp(lc1) or symbolp(lc1) then lc1*lc2
121 else if tenpr(lc2) then /* so name(LC1)=LC */
123 if verbify(name(lc2))=levi_civita and tenpr(lc1) then
124 ( /* again test if LC1 is a single */
134 ln11:makelist(idummy(),i,1,lf),
135 kdelta(ln11,l22)*prod(ev(imetric)([-ln11[i%],-l11[i%]],[]),i%,1,lf)
140 ln11:makelist(idummy(),i,1,lf),
141 kdelta(l2,ln11)*prod(ev(imetric)([l1[i%],ln11[i%]],[]),i%,1,lf)
149 if numberp(lc2) or symbolp(lc2) then lc2*lc1
152 temp1:_extlc(lc1,lc2),
153 _lcprod(lc1,temp1)*(lc2/temp1)
159 _extlc(lc1,lc2):=block([temp],
162 temp:part(num(lc2),1,1),
163 if tenpr(temp) and verbify(name(temp))=levi_civita and conti(temp)#[] then temp
168 temp:part(num(lc2),1,1),
169 if tenpr(temp) and verbify(name(temp))=verbify(name(lc1)) and covi(temp)#[] then temp