I have this list of numbers
num = [3.700872591587623, 3.083141235300246, 3.700872591587623, 2.321928094887362, -0.0, 5.088040034713085, 3.8079321155203494, 3.0, 3.8079321155203494, 3.700872591587623, -0.0, -0.0, 5.088040034713085, 5.088040034713085, 3.8079321155203494, 3.8079321155203494]
And I have these three smaller partitions of the above list
list_1 = nums[:5] # Elements 0 to 4
list_2 = nums[5:-1] # Elements 5 to len(list) - 1
list_3 = nums[-1:] # Element len(list) - 1
Equivalence test:
>>> nums == list_1 + list_2 + list_3
True
When I sum the bigger list, I get the following value
>>> sum(nums)
50.003535671171136
But when I sum the smaller lists, and add them together, I get a different value (logically they should give you the same value)
>>> sum(list_1) + sum(list_2) + sum(list_3)
50.00353567117113
Specifically, sum(nums)
gives a value that is 0.00000000000006 larger. This minor difference fails an equivalence test, which makes a difference in the decision making in my program. I'd like those two operations to be executed "reliably". Is there a way to ensure that?