Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
documentation:ref:collect [2015/11/20 20:28]
poslavskysv [Description]
documentation:ref:collect [2015/11/20 20:32]
poslavskysv [Description]
Line 2: Line 2:
 ---- ----
 ====Description==== ====Description====
-  * ''​Collect[var1,​ var2, ..., [transformations]]''​ collects together terms involving the same powers of specified vars and applies specified transformations to the expression that forms the coefficient of each term obtained+  * ''​Collect[var1,​ var2]''​ collects together terms involving the same powers of specified vars.
  
 +  * ''​Collect[var1,​ var2, ..., transformations]''​ or ''​%%Collect[var1,​ var2, ..., [Simplifications:​ transformations]]%%''​ additionally applies specified ​ transformations to the expression that forms the coefficient of each term obtained. ​
  
   * In the case of tensorial vars, ''​Collect''​ will insert [[documentation:​ref:​Kronecker delta|Kronecker deltas]] or [[documentation:​ref:​metric tensor|metric tensors]] in order to "​uncontract"​ indices and factor out tensorial parts.   * In the case of tensorial vars, ''​Collect''​ will insert [[documentation:​ref:​Kronecker delta|Kronecker deltas]] or [[documentation:​ref:​metric tensor|metric tensors]] in order to "​uncontract"​ indices and factor out tensorial parts.
Line 10: Line 11:
   * In the case of scalar vars, the behaviour of ''​Collect''​ is similar to other CASs.    * In the case of scalar vars, the behaviour of ''​Collect''​ is similar to other CASs. 
  
-  * To prevent expand of symbolic terms when collecting tensors one can use option ''​%%Collect[[vars, [ExpandSymbolic:​ true]]%%''​+  * To prevent expand of symbolic terms when collecting tensors one can use option ''​%%Collect[[var1, var2, ..., [ExpandSymbolic:​ true]]%%''​
 ====Examples==== ====Examples====
  
Line 65: Line 66:
    > A_c*B^d*(d_a^c*d^b_d+g_ad*g^bc)+(C^b*d_a^c+g^bc*D_a)*A_c    > A_c*B^d*(d_a^c*d^b_d+g_ad*g^bc)+(C^b*d_a^c+g^bc*D_a)*A_c
 </​sxh>​ </​sxh>​
 +
 +----
 +
 +
 +By default ''​Collect''​ will expand all expressions:​
 +<sxh groovy; gutter: true>
 +def t = '​(a+b)**2 * A_a * B^b + A^b * B_a'.t
 +println Collect['​B_m'​] >> t
 +</​sxh>​
 +<sxh plain; gutter: false>
 +   > B_{c}*((b**2+a**2+2*b*a)*A_{a}*g^{bc}+A^{b}*d_{a}^{c})
 +</​sxh>​
 +To prevent this overhead one can use:
 +<sxh groovy; gutter: true; first-line: 3>
 +println Collect['​B_m',​ [ExpandSymbolic:​ false]] >> t
 +</​sxh>​
 +<sxh plain; gutter: false>
 +   > B_{c}*((a+b)**2*A_{a}*g^{bc}+A^{b}*d_{a}^{c})
 +</​sxh>​
 +
  
 ---- ----