Let $A, B$ be two sets and take $A \times B$ be the Cartesian product set. I am wondering under what conditions on $A,B$ that the following equality always holds or not:
$$\sum_{(x,y) \in A \times B} f(x,y) = \sum_{x \in A} \sum_{y \in B} f(x,y). $$
I found a link https://proofwiki.org/wiki/Summation_over_Cartesian_Product_as_Double_Summation that closely related to this problem but it requires that $A, B$ are finite sets. Can it be all countable sets? can it be all uncountable sets, say $A=B=\mathbb{R}$ or $A=\mathbb{R}$? I fail to see why not. Any help is appreciated.