====== ExpandAndEliminate ====== ---- ====Description==== * ''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''. * When no metric tensors or Kronecker deltas involved, ''ExpandAndEliminate'' works same as ''Expand''. * ''ExpandAndEliminate[simplifications]'' or ''%%ExpandAndEliminate[[Simplifications: simplifications]]%%'' will apply additional simplifications at each level of expand procedure ====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: //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. ====See also==== * Related guides: [[documentation:guide:applying_and_manipulating_transformations]], [[documentation:guide:list_of_transformations]] * Related transformations: [[documentation:ref:expand]], [[documentation:ref:eliminatemetrics]] * JavaDocs: [[http://api.redberry.cc/redberry/1.1.9/java-api/cc/redberry/core/transformations/expand/ExpandTransformation.html|ExpandTransformation]] * Source code: [[https://bitbucket.org/redberry/redberry/src/tip/core/src/main/java/cc/redberry/core/transformations/expand/ExpandTransformation.java|ExpandTransformation.java]]