MathGroup Archive 2011

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

Search the Archive

Re: Unwanted Recursion

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120069] Re: Unwanted Recursion
  • From: Simon <simonjtyler at gmail.com>
  • Date: Thu, 7 Jul 2011 07:33:05 -0400 (EDT)
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

Writing these type of replacement rules for functions with the Flat can be confusing. This is because of how Flat (and OneIdentity) act in the Mathematica pattern matching algorithms.

There are two (AFAIK) options:
1) Don't use Flat & OneIdentity in your anticommutative multiplication. Instead implement these properties using your own patterns. See e.g. http://library.wolfram.com/infocenter/Conferences/325/
2) Don't write DownValue / UpValue rules for p[a_] and p[]. Instead, manually apply those simplifications at the end of each calculation. This is probably the more optimal way to go. It can even be automated with 
$Post=(#/.{p[a_]:>a,p[]->1}&)

If anyone has a more direct solution (or black magic solution) to combining the Flat attribute and p[]=1 type definitions, I'd be interested in seeing them. 


  • Prev by Date: How to NSolve equation which involves NIntegrate?
  • Next by Date: Re: Unwanted Recursion
  • Previous by thread: Re: Unwanted Recursion
  • Next by thread: Re: Unwanted Recursion