I admit I’m a bit desperate for a solution here, I have defined in Mathematica:
- A basis
newBasis(built from a functionf[c[i],c[j],c[k]]). - A set of rewrite rules
reorderIndicesandadjReprto put thosef[…]into a canonical form. - A set of “product‐to‐
**” rules
matrixProduct := {
A_[a_][i_, j_] B_[b_][j_, k_] -> A[a] ** B[b][i, k],
A_[a_] ** B_[b_][i_, j_] C_[c_][j_, k_] ->
A[a] ** B[b] ** C[c][i, k],
A_[a_] ** B_[b_][j_, i_] C_[c_][k_, j_] ->
C[c] ** A[a] ** B[b][k, i],
resta___ ** a___[i_, j_] restb___ ** b___[j_, k_] ->
resta ** a ** restb ** b[i, k]
}
When I do
basis = newBasis /. reorderIndices[5] //. adjRepr;
basis = basis //. matrixProduct;
cBasis = complexConjugate[basis];
cBasis = cBasis //. matrixProduct;
everything converges fine. But as soon as I compute
c = Table[If[i <= j, basis[[i]] cBasis[[j]], 0], {i, 1, 6}, {j, 1, 6}]
I get
$RecursionLimit::reclim: Recursion depth of 1024 exceeded.
How can I multiply basis[[i]] and basis[[j]] in a Table without triggering infinite rewrites? Any pointers to how to avoid the infinite recursion inside Table?
Thanks in advance for any insight!
cappears in your code. I wouldn't be surprised if acturned up inside theTableexpression that you're using to definec. $\endgroup$C(uppercase) is a reserved symbol. It's probably not a problem in this specific case, but in general it's best to avoid name clashes with built-in symbols. IfChad evaluation rules, then your replacement rules could be doing something very different. $\endgroup$matrixProductlooks dangerous. Because of the use of lots ofBlankNullSequences (triple underscores like___) it looks like that pattern might match the right-hand side of that same rule, leading to an infinite recursion. You might want to replace___with__(double underscores, i.e.BlankSequence. $\endgroup$