ExpandAndEliminate
Description
Examples
Expand 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}
|
Details
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:
def randomTensor = new RandomTensor()
randomTensor .clearNamespace ()
randomTensor .addToNamespace ( 'g_mn' .t , 'A_m' .t )
def a, b
for ( def i in 0 .. 1000 ) {
def t = randomTensor .nextTensorTree ( 4 , 3 , 8 , '_a' .si )
timing {
a = ExpandAndEliminate > > t
}
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.
|
See also