CollectScalars


Description

  • CollectScalars collects similar scalar factors in products.

Examples


Collect same scalars in product:

println CollectScalars >> 'A_m*A^m*A_n*A^n'.t
   > (A_{m}*A^{m})**2


CollectScalars may significantly simplify expression:

println CollectScalars >> 't_mn*f^mn*t_ba*f^ba*R_ij + (t_mn*f^mn)**2*R_ij'.t
   > 2*(t_{mn}*f^{mn})**2*R_{ij}


CollectScalars takes into account symmetries of tensors:

setSymmetric 't_mn'
println CollectScalars >> 't_mn*f^mn*t_ab*f^ba*R_ij'.t
   > (t_{mn}*f^{mn})**2*R_{ij}


CollectScalars collects scalars with any complicated structure:

println CollectScalars >> '(A_i + B_i)*(A^i + B^i)*(A_a + B_a)*(A^a + B^a)'.t
   > ((A^{a}+B^{a})*(A_{a}+B_{a}))**2


See also