[Date Index]
[Thread Index]
[Author Index]
Re: Creating an Attribute AntiSymmetric ?!?!?!
*To*: mathgroup at smc.vnet.net
*Subject*: [mg6316] Re: [mg6279] Creating an Attribute AntiSymmetric ?!?!?!
*From*: Paul Abbott <paul at physics.uwa.edu.au>
*Date*: Sat, 8 Mar 1997 00:26:41 -0500 (EST)
*Organization*: University of Western Australia
*Sender*: owner-wri-mathgroup at wolfram.com
Bjoern Hassler wrote:
> is there a way of creating your own Attributes?
Not that I'm aware of -- someone at WRI should answer this.
> In particular I am looking for an attribute which
> work like Orderless (especially in wrt. to pattern
> matching), but makes a function totally anti(skew)-
> symmetric, rather than totally symmetric.
The following ideas have appeared in various issues of the Mathematica
Journal. It is easy to construct a general antisymmetric function f
using
In[1]:= Antisymmetrize[f_] := Module[{perm = Permutations[f]},
Plus @@ (Signature[f] perm Signature /@ perm)]
For example,
In[1]:= Antisymmetrize[f[a, b, c]]
Out[2]= f[a, b, c] - f[a, c, b] - f[b, a, c] + f[b, c, a] +
f[c, a, b] - f[c, b, a]
By including Signature[f]in the definition of Antisymmetrize, initially
cyclic and anticyclic permutations are distinguishable:
In[3]:= Antisymmetrize[f[b, a, c]]
Out[3]= -f[a, b, c] + f[a, c, b] + f[b, a, c] - f[b, c, a] -
f[c, a, b] + f[c, b, a]
The rule
In[4]:= f[x__ /; !OrderedQ[{x}]] := Signature[{x}] f @@ Sort[{x}]
attached to f, ensures that it is antisymmetric independent of the
number of its arguments. An example illustrates the utility of the
technique:
In[5]:= Factor[h[a] f[a, b] - h[b] f[b, a]]
Out[5]= f[a, b] (h[a] + h[b])
Note that this works correctly in combination with Antisymmetrize above:
In[6]:= Antisymmetrize[f[a, b, c]]
Out[6]= 0
Alternatively, instead of attaching a rule to a function we can use a
replacement rule:
In[7]:= Factor[h[a] g[a, b] - h[b] g[b, a] /.
g[x__] :> Signature[{x}] Sort[g[x]]]
Out[7]= g[a, b] (h[a] + h[b])
This has the advantage that we now have control over when the
transformation is applied and also we don't have to worry about
forgetting that a rule has been attached to a function.
Cheers,
Paul
_________________________________________________________________
Paul Abbott
Department of Physics Phone: +61-9-380-2734
The University of Western Australia Fax: +61-9-380-1014
Nedlands WA 6907 paul at physics.uwa.edu.au
AUSTRALIA http://www.pd.uwa.edu.au/Paul
God IS a weakly left-handed dice player
_________________________________________________________________
Prev by Date:
**How to use Needs inside While?**
Next by Date:
**Re: Re: Windows front end**
Previous by thread:
**Re: Creating an Attribute AntiSymmetric ?!?!?!**
Next by thread:
**Re: Creating an Attribute AntiSymmetric ?!?!?!**
| |