# How do I notate iteration through unique pairs in a set?

My background is computing so I'm not a pro at maths by any stretch. But I'm writing up some research and I want to notate the summation of some function of all unique pairs in a set (aside from pairs with two of the same item).

I thought of writing:

$$\alpha(X) = \frac{\sum_{i=1}^{\lvert X\rvert} \sum_{j=i+1}^{\lvert X\rvert} f(x_i,x_j)}{\frac{1}{2}\lvert X\rvert(\lvert X\rvert-1)}, \{x_i,x_j\} \subset X.$$

However, because $$X$$ is a set I have assumed this is wrong because sets are unordered. According to wikipedia I have to introduce some kind of index set. I'm not sure how to notate this though and it seems like what I'm trying to express should be able to be notated more concisely.

I thought an alternative would be to write something along these lines (even though this isn't correct):

$$\alpha(X) = \frac{\sum_{x_1 \in X} \sum_{x_2 \in X}f(x_1,x_2)}{\frac{1}{2}\lvert X\rvert(\lvert X\rvert-1)}, x_1 \neq x_2$$

However this expresses a summation that sums most pairs twice even though $$f(x,y)$$ is commutative. Because I cannot use an index I can't express that I only want to go over each unique pair once in the summation.

How should one notate what I am trying to express?

Let $$P$$ be the set of all pairs $$(a,b)$$ of elements of $$X$$. Then let $$\alpha(X) = \sum_{(a,b) \in P}f(a,b).$$
In your definition of $$P$$ be sure to tell the reader that the pairs are unordered, that the elements must be distinct, and that $$\alpha$$ is well defined because $$f(a,b) = f(b,a)$$. ("commutative" is the wrong word for that.)
• Shouldn't it be $f((a,b))$? – Don Thousand Sep 6 '19 at 22:03
• @DonThousand The first sentence is "...your goal is clarity, not formality." Is the notation unclear? Is it necessary to write $f((a,b))$ in order to guarantee clarity? If not, I think that $f(a,b)$ is better... – Xander Henderson Sep 6 '19 at 22:24
• Could drop $P$ and use $(a,b)\in X\times X$ – MPW Sep 6 '19 at 22:29