ExpandAndEliminate
expands out product of sums and positive integer powers and permanently eliminates metric and Kronecker deltas.ExpandAndEliminate
is equivalent to sequential applying Expand & EliminateMetrics
but works faster since applies EliminateMetrics
at each level of expand procedure.ExpandAndEliminate
is equal to Expand[EliminateMetrics] & EliminateMetrics
.ExpandAndEliminate
works same as Expand
.ExpandAndEliminate[simplifications]
or ExpandAndEliminate[[Simplifications: simplifications]]
will apply additional simplifications at each level of expand procedureExpand product of sums and eliminate metrics:
def t = '(A_a*g_mn + A_m*g_an + A_n*g_am)*(A^a*g^mn + A^m*g^an + A^n*g^am)'.t println ExpandAndEliminate >> t
> 6*A_{n}*A^{n}+3*d^{n}_{n}*A_{m}*A^{m}
When no metric tensors or Kronecker deltas involved, ExpandAndEliminate
works same as Expand
:
println Expand >> '(A_m^m + 1)**3'.t
> 3*A_{m}^{m}*A_{a}^{a}+A_{m}^{m}*A_{a}^{a}*A_{b}^{b}+1+3*A_{b}^{b}
ExpandAndEliminate
is equivalent to sequential applying Expand & EliminateMetrics
but works faster since it applies EliminateMetrics
at each level of expand procedure. One can check the advantages of ExpandAndEliminate
in the following example with random tensors:
//create random generator, which generates // random tensors consisting of metric and A_m def randomTensor = new RandomTensor() randomTensor.clearNamespace() randomTensor.addToNamespace('g_mn'.t, 'A_m'.t) def a, b //loop to warm up JVM for (def i in 0..1000) { //next random tensor def t = randomTensor.nextTensorTree(4, 3, 8, '_a'.si) //this will typically 10 times faster timing { a = ExpandAndEliminate >> t } //than this timing { b = (Expand & EliminateMetrics) >> t } assert a == b println '' }The sample output will looks like:
Time: 14 ms. Time: 88 ms. Time: 52 ms. Time: 553 ms. Time: 40 ms. Time: 577 ms.