I am trying to introduce a rule of multiplication of entries of a matrix which would have the following property:
delta[k,i]*delta[k,j]=delta[k,i]*delta[i,j] and then produce some manipulation with the matrix, for example, calculate its square with respect to this rule. How can I introduce such rule in Mathematica? Of course, the multiplication of entries which have not equal indexes should be usual one.
UPD Also delta is symmetric. So, I expect instead of
In[1]:= Clear[delta]; delta[k_, i_]*delta[k_, j_] :> delta[k, i]*delta[i, j]; delta[k_, i_] :> delta[i, k]; FullSimplify[delta[0, 1] (delta[0, 2] - delta[2, 1])] Out[33]= delta[0, 1] (delta[0, 2] - delta[2, 1]) to get 0 as the answer.
KroneckerDelta? If so, can you provide more details about your actual use-case? It's a little unclear exactly what you would need. Something like a replacementRulethat looks inside expressions and sees when arguments todeltas overlap could work, but we need more info. For instance, are you manipulating symbolic matrices defined with thesedeltas? Are repeated indices implicitly summed over? Etc. $\endgroup$delta[k_, i_]*delta[k_, j_] :> delta[k, i]*delta[i, j]. ( This may not work if your products are actually embedded in more complicated expressions ) $\endgroup$deltaorderless then a replacement rule for zero might suffice:In[1391]:= Clear[delta]; Attributes[delta] = {Orderless}; In[1393]:= Expand[delta[0, 1] (delta[0, 2] - delta[2, 1])] /. delta[k_, i_]*delta[k_, j_] - delta[k_, i_]*delta[i_, j_] :> 0 Out[1393]= 0$\endgroup$