0
$\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$
  • $\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$ – aardvark2012 Dec 1 '17 at 1:08
  • $\begingroup$ @aardvark2012 good point. I will change it. $\endgroup$ – user143410 Dec 1 '17 at 1:12
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.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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