# [✓] Avoid rule based programming iteration limit exceeded?

GROUPS:
 Hello,I'm trying ti define abstract mathematical unevaluated objects such as e[1], e[1,2], e[1,2,3], etc. There are rules for these objects, such as e[]=1 e[1,1]=e[2,2]=..=e[i,i]=e[]=1 e[1,2]=e[1,2] e[2,1]=-e[1,2] e[1,2,3]=e[1,2,3] e[2,1,3]=-e[1,2,3] e[2,3,1]=e[1,2,3], etc. The number of argument inside e is arbitrary but I'm first trying with two, to further generalize. I found that the following code works pretty well for this case: e[] := 1 e[i_Integer, i_Integer] := e[] e[i_Integer, j_Integer] := -e[j, i] /; i != j && i > j However the following one, which should produce the same result, but is more general and useful when trying to generalize to more than two arguments, fails: e[] := 1 e[i_Integer, i_Integer] := e[] e[i_Integer, j_Integer] := Signature[{i, j}] e @@ Sort[{i, j}] /; i != j since a Recursion Limit is exceeded.Can anyone give me some clue about why this happens? Thanks a lot in advance,Jose L. Aragon
11 months ago
4 Replies
 Sorry but in my previous post, formulae and Mathematica commands where written in a single line. These are: e[]=1 e[1,1]=e[2,2]=..=e[i,i]=e[]=1 e[1,2]=e[1,2] e[2,1]=-e[1,2] e[1,2,3]=e[1,2,3] e[2,1,3]=-e[1,2,3] e[2,3,1]=e[1,2,3], etc. The first successful attempt is: e[] := 1 e[iInteger, iInteger] := e[] e[iInteger, jInteger] := -e[j, i] /; i != j && i > j an the unsuccessful one is: e[] := 1 e[iInteger, iInteger] := e[] e[iInteger, jInteger] := Signature[{i, j}] e @@ Sort[{i, j}] /; i != j Thanks,Jose L. Aragon
 Neil Singer 1 Vote Jose,your problem is that you define e[1,2] (or -e[2,1]) to be e[1,2] -- which then enters an infinite loop (e[1,2] triggers your rule again and again evaluates to e[1,2]. You need to end the recursion.You first way works because once the order of i and j is in sort order it just returns e[i,j] because the condition on i>j is no longer met.Your posting lost all the underscores -- you need to use the code sample.I think you need to add a condition: e[i_Integer, j_Integer] := Signature[{i, j}] e @@ Sort[{i, j}] /; i != j && i > j 
 Welcome to Wolfram Community! Please EDIT your posts to make corrections, - do NOT post same content twice.Please make sure you know the rules and how to format your code properly, which you can find here: https://wolfr.am/READ-1ST If you do not format code, it may become corrupted and useless to other members. Please EDIT your posts and make sure code blocks start on a new paragraph and look framed and colored like this. int = Integrate[1/(x^3 - 1), x]; Map[Framed, int, Infinity]