Wolfram alpha is actually wrong here.
(1 - 0.002) ** 5
is exactly 0.990039920079968
.
You can verify that by simply assessing that there are 15 digits after the .
, which matches 5 * 3
, 3 being the number of digits after the .
in the expression (1 - 0.002)
. There couldn't be any digit after the 15th by definition.
Edit
A little more digging got me something interesting:
This notation Decimal('0.002')
creates an actual decimal with this exact value. Using Decimal(0.002)
the decimal is made from a float rather than a string, creating an imprecision. Using this notation is the original formula :
(1-decimal.Decimal(0.002))**5
Returns Decimal('0.99003992007996799979349352807411754897106595345737537649055432859002826694496107'
which is indeed 80 digits long after the .
, but different from the wolfram alpha value.
This is probably caused by a difference of precision between python and wolfram alpha floating point representation, and is a further indication that wolfram alpha is using floats when SetPrecision is used.
Nota: directly asking for the result returns the correct value (see http://www.wolframalpha.com/input/?i=%281+-+0.002%29%5E5).