Problem in calculation of daily expense

35 Views Asked by At

I have a simple question.

Total amount = 50 USD

-----------------------------
- Expense     |   Remaining |
-----------------------------
- 20          |   30        |
-----------------------------
- 15          |   15        |
-----------------------------
- 9           |   6         |
-----------------------------
- 6           |   0         |
=============================
- 50          |  51         |
=============================

As you can see at the end value is not the same. If we calculate Expense and Remaining both value has changed. There is one more in Remaining balance.

Can you please let me know what is the problem, which I'm doing wrong.

2

There are 2 best solutions below

0
On BEST ANSWER

The short answer is that althought the difference of the 2 sums is only 1, it is because the sum in the second column does not represent the same fact as the sum in the first column. In fact, as explained below, the sum in the second column has no meaning relevant to the issue at hand.

To find the "Total Expenses", we sum each expense as you did in column 1:

$E=-e1-e2-e3-e4 = -50$

Now, for the column you named "Remaining" the sum has no mathematical meaning or significance. Why? Let me explain. Let's go back to what is calculated in the sum "Remaining" column, the sum can be written as follows:

$S=50-e1 + [50-e1]-e2 + [50-e1-e2] -e3 + [(50-e1)-e2-e3]-e4$

$S=4*50 - 4*e1 - 3*e2 - 2*e3 - 1*e4 = $

$4*(50)+4*(-20)+3*(-15)+2*(-9)+1*(-6)=51$

Notice that the above formula has no meaning or significance. It clearly does not represent the total expense, so it is no wonder that it differs from the correct total expense.

The fact that the absolute difference is only by value of $1$ from the sum of the left column is by chance! Had you started with an amount of 200 and applied the same calculations, the first column sum would still give $-50$ but the right (bogus) sum would give $651$. I hope this is now clear.

0
On

Generally speaking, your expenses are $a_1, a_2, \ldots, a_n$ and must add up to $\sum_{k=1}^n a_k = T,$ your total amount. If you look at the sum in the other column, it is actually summing the partial sums of the first one, so it is $\sum_{k=1}^{n-1} s_k$ where $s_k = \sum_{i=1}^k a_i$. In other words, you get $$ \sum_{k=1}^{n-1} \sum_{i=1}^k a_i = \sum_{i=1}^{n-1} (n-i)a_i = n \sum_{i=1}^{n-1} a_i - \sum_{i=1}^{n-1}ia_i = nT - \sum_{i=1}^{n-1}ia_i, $$ and there is absolutely no reason why that expression should equal $T$...