Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

Can I define a relation between variables, such that the expression will also be evaluated (then assuming all indices are equal) when no index is given? $$ x_i + y_j = \delta_{ij} \stackrel{Mathematica\ recognizes \ then\ that}{\Rightarrow} x + y = \delta_{ii} = 1 $$ $$$$ $$$$

INITIAL QUESTION WAS: I define a relation for the annihilation and creation operator $a_i$ and $a_j$ like this $$[a_i, a_j^\dagger] = \delta_{ij}.$$

The commutator can be defined with the Quantum Notation package. I want to make the index ($i$, resp. $j$) optional, such that Mathematica recognizes that $$[a, a^\dagger] =1,$$ i.e. it assumes $i=j$ if no index is given. Is there a way to do this?

share|improve this question
how do you currently define the relation? (for existing indices) – Pinguin Dirk Oct 4 '13 at 6:35
showing us your code could make things easier – Wizard Oct 4 '13 at 15:39
Dear Wizard, Dear Pinguin Dirk, I actually define the relation exactly like this $$[a_i, a_j^\dagger] = KroneckerDelta[ij],$$ since the Quantum Notation package supports commutator notation. I just asked out of curiosity, in the moment I am using the "double definition" (one time with and one time without indices) as swish suggested. – ahambi Oct 5 '13 at 18:10

I have this package installed, so that's what I did, and everything worked:

enter image description here

share|improve this answer
Could you please 1) provide a link to the Quantum notation package and 2) edit in the real copyable code instead of the image? – István Zachar Feb 27 '14 at 12:08

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.