I try to understand why the sequence of operations forward and backward produces different final results (293.02992793 vs 293.02992793000004)? Could you please help with the explanation?
cf = [100, 50, 40, 20, 30, 25]
rate = 1.03
FV = 0
for i in range(len(cf)):
print(i,' ',FV)
FV += cf[i] * rate**(len(cf)-i-1)
print(FV)
FV = 0
i = len(cf) - 1
while i>=0:
print(i,' ',FV)
FV += cf[i] * rate**(len(cf)-i-1)
i = i-1
print(FV)
cf = cf[::-1]
FV = 0
for i in range(len(cf)):
print(i,' ',FV)
FV += cf[i] * rate**(i)
print(FV)
0 0
1 115.92740743
2 172.20284793000002
3 215.91192793000002
4 237.12992793
5 268.02992793
293.02992793
5 0
4 25.0
3 55.900000000000006
2 77.11800000000001
1 120.82708000000001
0 177.10252050000003
293.02992793000004
0 0
1 25.0
2 55.900000000000006
3 77.11800000000001
4 120.82708000000001
5 177.10252050000003
293.02992793000004