MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Define an antisymmetric function

  • To: mathgroup at
  • Subject: [mg107449] Re: Define an antisymmetric function
  • From: Szabolcs <szhorvat at>
  • Date: Fri, 12 Feb 2010 06:58:05 -0500 (EST)
  • References: <hl0r36$uu$> <>

On Feb 12, 11:44 am, Torsten Schoenfeld <kaffeetisch at> wrote:
> On 12.02.10 10:45, Leonid Shifrin wrote:
> > ClearAll[G];
> > G[a, b] := f[a, b]
> > G[a, c] := g[a, c]
> > G[b, c] := h[b, c]
> > G[x_, y_] := -G[y, x] /;
> >    Hold[G[y, x]] =!= (Hold[G[y, x]] /. Most@DownValues[G])
> This actually works perfectly fine even if pattern-based definitions are
> involved!  (Pattern-based definitions appear normally in DownValues.) I
> neglected to mention it, but G[_, _] is also supposed to act as a
> derivative in both slots, e.g. G[x_, y_^2] := 2 G[x, y] y.  Your
> approach handles this gracefully: G[x^2, y] yields -2 x G[y, x].
> So, thanks a lot!  Thanks also for all the other suggestions in this
> thread; I learned many nice tricks.

I believe that what Leonid referred to when he said that it might not
work if you add pattern based definitions later on was that this
approach assumed that the "antisymmetry definition" is the very last
one in the DownValue list.  Mathematica tries to automatically order
definitions from most specific to most general, but this is not always
possible.  When it can't do this, it just adds rules to the DownValue
list in the order they were defined.  So a general pattern based
definition *may* displace the antisymmetry rule from the very last
position, especially if it is added later.  Just be careful with the
order in which definitions are made.

  • Prev by Date: Re: Define an antisymmetric function
  • Next by Date: Re: Re: second , third and fourth derivatives of a
  • Previous by thread: Re: Define an antisymmetric function
  • Next by thread: Re: Re: Define an antisymmetric function