Re: Bug in Decimal??

```On Sunday, May 4, 2014 6:53:06 AM UTC-4, Mark Dickinson wrote:

> I had a quick look: this isn't a bug - it's just the result of propagation of
>
> the error in "partial" to "final".
>
>
>
> In more detail: we've got a working precision of 2016 significant figures.
> For
>
> any small x, we have (1 + x) / (1 - x) = 1 + 2x + 2x^2 + 2x^3 + ....  For your
>
> value of x, `Decimal('1e-1007'), we've got enough precision to store
>
> 1 + 2x + 2x^2 exactly, but that's all.
>
>
>
> So partial has an absolute error of around 2x^3, or 2e-3021.
>
>
>
> And since the derivative of the natural log function is almost exactly 1 at
> the
>
> point we're interested in, we expect the absolute error in the output to be
>
> close to 2e-3021, too.
> ```
```
Please take a deeper look at my second post. Try the same but this time set the
precision to 4000, 8000 or whatever you need to convince yourself there's no
error propagation, yet there's a 4 in the middle that shouldn't be there. See
for yourself!

I've tested on all platforms I know of and confirmed it. The wrong digit occurs
in the middle of the number. Propagation error would have a bad digit near the
end, and garbage after that. Here there's a perfect sequence of numbers, but
with one single digit changed in the middle of the number.
No error propagation in a series expansion can do that.

I generated a table of 1000 numbers, one correctly generated and one with
mpdecimal. Then I did a diff of both files and it's horrible. The difference is
all over the place, sometimes as high as digit 500 (out of 2000). Almost every
result has the bad digit somewhere. The bad digit moves around a lot, from
about position 500 to 2000. All other digits are correct, and in a 2000 digit
sequence is hard to spot the difference (I used the visual diff tool that comes
with TortoiseSVN or TortoiseGit). I think there's a bad pointer or something
that's rounding the wrong digit.
You cannot possibly have 1999 correct digits and only 1 changed on every number
if it was propagation error.

I'll follow up directly with the author of mpdecimal, as this is somewhat
serious on a language that's so widely used as python.

But please test it and confirm, am I seeing ghost digits?
--
https://mail.python.org/mailman/listinfo/python-list
```