/* FileName: SymbolicTensorCalculus.mac Contents: maxima program to manupulate the algebra of tensor 2022/12/8: created by Hideo Kodama from SymbolicTensorCalculus.mpl 2022/12/15: symmetrizeT -- bug fix. 2022/12/16: maxima bug on the confusion of local and global variables are coped with. 2022/12/16: verion 1.00 LastUpdate: 2022/12/16 */ /******>Top */ /*****>packages */ LibPath: pathname_directory(load_pathname)$ load(concat(LibPath,"mylib_list_v1_00_pub.mac"))$ /*****>convention */ /****>global variables */ /******>Basic program */ /*****>(anti-)symmetrization*/ /****>proc: symmetrize */ /* symmetrize(eq, indset,type) => new eq (anti-)symmetrized wrt indlist eq=algebraic expression containg indeces in the index list "indset" indset= index set [a,b,, .] to symmetrize type = s/a or 1/-1 (symmetrize/anti-symmetrize) */ symmetrize(eq, indset, type) := block( [ /*list*/ pindlist, /* misc*/ tmp,x1,x2,r, sgn ], eq: expand(eq), r: length(indset), if (type='a or type=-1) then ( sgn : -1 ) else ( sgn :+1 ), /*end if*/ if op(eq)="+" then ( return (map(lambda([x], symmetrize(x, indset, type)), eq)) ) else ( pindlist: permlist(indset), x1: lsum(at(eq, makelist( indset[i]=y[i], i, 1, r)), y, pindlist[1]), x2: sgn* lsum(at(eq, makelist( indset[i]=y[i], i, 1, r)), y, pindlist[2]), return ( (x1+x2)/length(indset)! ) ) /*end if*/ )$ /*end proc: symmetrize*/ /****>proc:symmetrizeT */ /* symmetrizeT(eq,T, subindlist,type) => new eq in T (anti-)symmetrized wrt subindlist T = tensor name, eq=algebraic expression of T[a,b,... ], subindlist= subset of [a,b, ...] to symmetrize type = s/a or 1/-1 (symmetrize/anti-symmetrize) */ symmetrizeT(_ex0, T, subindlist, type) := block( [ /*list*/ _pindlist, /* misc*/ _ex, _xx, _cc, _rr, _sgn ], _ex: expand(_ex0), _rr: length(subindlist), if ( type= 'a or type=-1) then ( _sgn: -1 ) else ( _sgn : +1 ), /*end if*/ if op(_ex)="+" then ( return ( map(lambda([x], symmetrizeT(x, T, subindlist,type)), _ex)) ) else ( [_xx, _cc] : selectremove_has(T,_ex), _pindlist: permlist(subindlist), return ( 1/_rr!*( _cc*lsum(at(_xx, makelist(subindlist[i]=y[i], i, 1, _rr)),y, _pindlist[1]) +_sgn*_cc*lsum(at(_xx, makelist(subindlist[i]=y[i],i, 1, _rr)), y, _pindlist[2]) ) ) ) /*end if*/ )$ /*end proc: symmetrizeT */ /******>End */ print("loading SymbolicTensorCalculus.mac --- done");