Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an expression like this:

enter image description here

Assuming[m [\Element] Integers && n [\Element] Integers, 1/2 I J n (4-m n+n^2) KroneckerDelta[m,-n]]//FullSimplify

Now, since KroneckerDelta has attribute Orderless, that means it will sort things into canonical order, and since my expression has $n^2$ in it, I assume that's why it's evaluating the Kronecker for m->-n (I tried putting KroneckerDelta[n,-m] but got the same result). Now, technically this is correct. But I'd like that my expression was given in terms of m, not n. If I manually replace n by -m I get the desired output


but I'd like to get that automatically within Mathematica. Is that possible without explicitly doing the replacement /.n->-m?

share|improve this question
up vote 2 down vote accepted

The order depends of alphabetical ordering of n and m. Therefore exist simple solution with renaming n and m

FullSimplify[1/2 I J m (4 - n m + m^2) KroneckerDelta[n, -m]] /. {n -> m, m -> n}

enter image description here

share|improve this answer
I guess that will do :) Thanks – dingo_d Nov 24 '13 at 20:09
@dingo_d Since you've got more than 15 rep. you can upvote answers too. I'm just reminding because I see you've accepted answer with no upvote what is strange. – Kuba Nov 24 '13 at 21:31
Oh, sometimes I totally forget to do that :S Sorry, upvoated it now ^^ – dingo_d Nov 25 '13 at 8:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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