9.8. Mapping at specified positions
We use the package ExpressionManipulation` (written by David Park & Ted Ersek) to have full control on the positions of an expression
Suppose we have an expression like this, which is clearly 0 because U is antisymmetric and S is symmetric:
In[965]:=
Out[965]=
In[966]:=
Out[966]=
Each object in the expression can be identified in a tree-like form by its position. In this case there are four positions at level 1:
In[967]:=
Out[967]=
We can evaluate a given function at one or several positions:
In[968]:=
Out[968]=
In[969]:=
Out[969]=
In order to map a function over several terms simultaneously we need to make use of the concept of ExtendedPosition (also from the ExpressionManipulation` package) and the new function NewMapAt. See notes for ExtendedPosition and eP.
In[970]:=
Out[970]=
In[971]:=
Out[971]=
We can also localize a given pattern:
In[972]:=
Out[972]=
or map a function onto the occurrences of that pattern:
In[973]:=
Out[973]=
In[974]:=
Out[974]=
In case the expression is held, we can use EvaluateAt (also from the package ExpressionManipulation`) instead of MapAt:
In[975]:=
Out[975]=
In[976]:=
Out[976]=
In[977]:=
Out[977]=
Created by Mathematica (May 16, 2008) | ![]() |