Re: Define an antisymmetric function
- To: mathgroup at smc.vnet.net
- Subject: [mg107411] Re: [mg107396] Define an antisymmetric function
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Fri, 12 Feb 2010 04:40:12 -0500 (EST)
- References: <201002111154.GAA01070@smc.vnet.net>
Torsten Schoenfeld wrote:
> I'd like to define an antisymmetric function by giving its value on a
> set of known objects. I'm having trouble enforcing antisymmetry. Say I
> want to define G[_, _] on the objects {a, b, c}:
>
> G[a, b] := f[a, b]
> G[a, c] := g[a, c]
> G[b, c] := h[b, c]
>
> If I now enforce antisymmetry simply by
>
> G[x_, y_] := -G[y, x]
>
> then it mostly works (e.g., G[b, a] evaluates to -f[a, b]). But if I
> apply G to something that is not in {a, b, c}, then I run into an
> infinite loop: G[a, f[b]] yields "$RecursionLimit::reclim: Recursion
> depth of 256 exceeded."
>
> Ideally, I would like applications to unknown input to stay unevaluated
> (e.g., G[a, f[b]] just yields G[a, f[b]]). How can I achieve that while
> also enforcing antisymmetry?
>
One way to do this is to only assign to the ordered set of arguments,
then impose down values to handle out-of-order argument lists. For the
case of two arguments this can be done as below.
assignOrdered[G_,a_,b_,f_] :=
If[a===b, G[a,b] := 0,
If [OrderedQ[{a,b}], G[a,b] := f[a,b], G[b,a] := -f[a,b]]]
Here I replicate your assignments, plus another which gives the
arguments in non-OrderedQ form.
assignOrdered[G,a,b,f]
assignOrdered[G,a,c,g]
assignOrdered[G,b,c,h]
assignOrdered[G,d,c,k]
Now we impose antisymmetry.
G[a_,a_] := 0
G[a_,b_] /; !OrderedQ[{a,b}] := -G[b,a]
let's see what we have.
In[61]:= DownValues[G]
Out[61]= {HoldPattern[G[a, b]] :> f[a, b],
HoldPattern[G[a, c]] :> g[a, c],
HoldPattern[G[b, c]] :> h[b, c], HoldPattern[G[c, d]] :> -k[d, c],
HoldPattern[G[a_, a_]] :> 0,
HoldPattern[G[a_, b_] /; !OrderedQ[{a, b}]] :> -G[b, a]}
Quick test:
In[62]:= {G[x,y], G[y,x], G[c,d],G[d,c],G[x,a]}
Out[62]= {G[x, y], -G[x, y], -k[d, c], k[d, c], -G[a, x]}
Daniel Lichtblau
Wolfram Research
- References:
- Define an antisymmetric function
- From: Torsten Schoenfeld <kaffeetisch@gmx.de>
- Define an antisymmetric function