Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3551

Re: Unwanted Recursion

From Simon <simonjtyler@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Unwanted Recursion
Date 2011-07-07 11:44 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iv4662$f9m$1@smc.vnet.net> (permalink)

Show all headers | View raw


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. 

Back to comp.soft-sys.math.mathematica | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Unwanted Recursion Simon <simonjtyler@gmail.com> - 2011-07-07 11:44 +0000
  Re: Unwanted Recursion Kambis Veschgini <k.veschgini@thphys.uni-heidelberg.de> - 2011-07-08 08:59 +0000

csiph-web