I want to compute a double sum like below with i != j. (When i =j, the denominator will be zero, which can not be assessed). Does anyone know how to do it? I want to skip the calculation when i=j.
Sum[1/(i-j),{i,1,10},{j,1,10}]
I found a appraoch like this:
pairs = Subsets[Range[10], {2}];
test[{i_, j_}] := 1/(i - j);
Total[test /@ datas]*2
which gives a result of -(4861/126), which is the anwser I need. But this method requires more time than the Sum funciton in Mathematica. (In addition, my function is more complex than the 1/i-j.
I would like to bid my sincere appreciate to any help.
2 Sum[1/(i - j), {i, 1, 10}, {j, 1, i - 1}]
$\endgroup$