I have a formula to be calculated such as; $|n_1 - n_2| + |n_3 - n_4|$. I want to calculate it with two tuples of values such as;
$(n_1,n_2)$ and $(n_3,n_4)$
When I try this method, it is equivalent;
$$|310-111| + |440-342| = (310 + 440) - (111 + 342)$$
When I try this method, it is also equivalent but this method won't work with above equation;
$$|111 - 309| + |342 - 207| = (342 - 111) + (309 - 207)$$
What is the problem here, where am I thinking wrong? Thanks in advance...
The issue, here, is that you're ordering your tuple, and using the given order as if it is important in some way. We can instead see that $$|310-111|+|440-342|=(440-111)+(310-342).$$
As for why this is the case, it is because $|x|=-x$ when $x$ is negative, and $|x|=x$ otherwise. So, we have: $$|310-111|=310-111\\|440-342|=440-342\\|111-309|=-(111-309)=-111+309=309-111\\|342-207|=342-207.$$ From the above, we can regroup (by commutativity, distributivity, and associativity), once we've removed the absolute value bars.
Since you seem to be looking for a general formula, here's one way we can go.
Observe that, regardless of $x,y$ we will necessarily have $|x-y|=\max(x,y)-\min(x,y).$ In the case that $x=y,$ this is easy to prove. In the case that $x>y,$ we know that $x-y>0,$ so that it's again easy to prove. In the case that $x<y,$ the third example above illustrates how we can prove it.
Given that, we have for any $n_1,n_2,n_3,n_4$ that $$|n_1-n_2|+|n_3-n_4|=\bigl(\max(n_1,n_2)-\min(n_1,n_2)\bigr)+\bigl(\max(n_3,n_4)-\min(n_3,n_4)\bigr),$$ or equivalently, $$|n_1-n_2|+|n_3-n_4|=\bigl(\max(n_1,n_2)+-\min(n_1,n_2)\bigr)+\bigl(\max(n_3,n_4)+-\min(n_3,n_4)\bigr).$$
At this point, we could use associativity to drop the parentheses, then use commutativity to obtain $$|n_1-n_2|+|n_3-n_4|=\max(n_1,n_2)+\max(n_3,n_4)+-\min(n_1,n_2)+-\min(n_3,n_4).$$ Now we can use distributivity (together with the identity $-x=-1\cdot x$ to see that
\begin{eqnarray}|n_1-n_2|+|n_3-n_4| &=& \max(n_1,n_2)+\max(n_3,n_4)+-1\cdot\min(n_1,n_2)+-1\cdot\min(n_3,n_4)\\ &=& \max(n_1,n_2)+\max(n_3,n_4)+-1\cdot\bigl(\min(n_1,n_2)+\min(n_3,n_4)\bigr)\\ &=& \max(n_1,n_2)+\max(n_3,n_4)+-\bigl(\min(n_1,n_2)+\min(n_3,n_4)\bigr)\\ &=& \bigl(\max(n_1,n_2)+\max(n_3,n_4)\bigr)-\bigl(\min(n_1,n_2)+\min(n_3,n_4)\bigr)\end{eqnarray}
This certainly isn't the only way we could formulate it, but it gets the job done.