1
$\begingroup$

Context: I have equations for indexed coefficients $C_{ij}$ which I have represented using 2-variable functions in Mathematica. e.g.,

c[2,1]+c[3,0]==0
c[1,2]+2c[2,1]+c[3,0]==0

etc.

Now, my coefficients are symmetric--i.e., $C_{ij}=C_{ji}$ so, when I use functions like Reduce/Solve or Simplify for these equations, I would like Mathematica to recognize $c[1,2]+2c[2,1]=3c[1,2]$, for example.

Question: How does one implement this index symmetry in Mathematica? The implementation of this need not use 2-variable functions; I'd be happy to use a different object type to represent my indexed coefficients.

$\endgroup$
2
  • $\begingroup$ Capital C has a built in meaning in Mathematica, see here. It's generally best not to use capitals so you can avoid conflicts. $\endgroup$ Dec 1, 2017 at 1:08
  • $\begingroup$ @aardvark2012 good point. I will change it. $\endgroup$
    – user143410
    Dec 1, 2017 at 1:12

1 Answer 1

2
$\begingroup$

At the beginning of your notebook, set the attribute of c to be Orderless.

SetAttributes[c, Orderless];

Then, all arguments of c will be sorted canonically, allowing you to solve for c in your subsequent equations.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.