Change the order of summation

In a computing context, if f(x,y) is a pure function then you can freely swap the order...

\(\displaystyle
\sum_{x=\mathit{c_1}}^{\mathit{c_2}}{ \left( \sum_{y=\mathit{c_3}}^{\mathit{c_4}}{f(x,y)} \right) }
=
\sum_{y=\mathit{c_3}}^{\mathit{c_4}}{ \left( \sum_{x=\mathit{c_1}}^{\mathit{c_2}}{f(x,y)} \right) }
\)

...but only if the variable that is holding the running sum does not overflow in either context.


In a mathematical context then I think a function is always pure? It might depend on the context and how the author has defined it.
 
...but only if the variable that is holding the running sum does not overflow in either context.

note that underflow (click) can also be a cause of different results if using floating point variables. If this might be happening then one solution is to use a variable type with extra precision.
 
Top