What is mathematical term to describe this confusion?

88 Views Asked by At

This is in reference to a question on stackoverflow - https://stackoverflow.com/questions/22445470/getting-more-data-while-converting-data-int-to-float-and-doing-division-and-mult#22445470

The following sql-scripts will generate values below, same code here in SQLFiddle with results

DECLARE @TableA TABLE
    (
     Students INT
    ,[Day] INT
    ,Shifts INT
    )
INSERT INTO @TableA
    VALUES  ( 129, 11, 4 )
,           ( 91, 9, 6 )
,           ( 166, 19, 8 )
,           ( 164, 26, 12 )
,           ( 146, 11, 6 )
,           ( 147, 16, 8 )
,           ( 201, 8, 3 )
,           ( 164, 4, 2 )
,           ( 186, 8, 6 )
,           ( 165, 7, 4 )
,           ( 171, 10, 4 )
,           ( 104, 5, 4 )
,           ( 1834, 134, 67 );


SELECT Students
       ,Day
       ,Shifts
       ,CAST(Day AS DECIMAL(12,1)) / CAST(Shifts AS DECIMAL(12,1)) Divs
       ,Students * (CAST(Day AS DECIMAL(12,1)) / CAST(Shifts AS DECIMAL(12,1))) StuDivs
FROM @TableA

    St      D   S       Div                 Stu*Div
    129     11  4       2.75000000000000    354.75000000000000
    91      9   6       1.50000000000000    136.50000000000000
    166     19  8       2.37500000000000    394.25000000000000
    164     26  12      2.16666666666666    355.33333333333224
    146     11  6       1.83333333333333    267.66666666666618
    147     16  8       2.00000000000000    294.00000000000000
    201     8   3       2.66666666666666    535.99999999999866
    164     4   2       2.00000000000000    328.00000000000000
    186     8   6       1.33333333333333    247.99999999999938
    165     7   4       1.75000000000000    288.75000000000000
    171     10  4       2.50000000000000    427.50000000000000
    104     5   4       1.25000000000000    130.00000000000000

Tot-1834    134 67      2.00000000000000    3668.00000000000000

So what OP wanted is for SUM(Students*(Days/Shifts))=SUM(Students)*(SUM(DAYS)/SUM(SHIFTS))? So it there mathematical term to describe this and should this ever be equal to each other. My math is really hazy been too many years since last math class.

1

There are 1 best solutions below

0
On BEST ANSWER

You are asking for, essentially, the conditions under which

$$\sum \frac{a_i b_i}{c_i} = \frac{\sum a_i \sum b_i}{\sum c_i}.$$

We can rewrite this as

$$\sum \frac{a_i b_i}{c_i} \sum c_i = \sum a_i \sum b_i.$$

The Cauchy-Schwarz inequality tells us that both sides are $\ge (\sum \sqrt{a_i b_i})^2$. Other than that, there's not much to be said. It could go either way.

For example, if our points are $(a_1, b_1, c_1) = (1, 1, 1)$ and $(a_2, b_2, c_2) = (1, 1, 1)$, then both sides are $2$ (in the original equation). If we have instead $(1, 1, 1)$ and $(1, 2, 3)$, then LHS ($5/3$) is greater than RHS ($3/2$). If we have $(1, 2, 1)$ and $(2, 1, 1)$, then LHS ($4$) is less than RHS ($9/2$).

Now, by the Cauchy-Schwarz equality condition, we do know that if all points are in the same ratio (e.g. $(1, 2, 3), (0.1, 0.2, 0.3), (4, 8, 12)$), then equality holds. However, this is only sufficient and not necessary; equality could hold between the two expressions even if Cauchy-Schwarz equality does not hold.

Unfortunately, I don't I can give much of a better answer than this: These are two different quantities, where one could be greater than, equal to, or less than the other.