String to Float, without introducing errors
MRAB
python at mrabarnett.plus.com
Mon Dec 19 10:14:14 EST 2022
On 2022-12-19 14:10, Peter J. Holzer wrote:
> On 2022-12-19 09:25:17 +1100, Chris Angelico wrote:
>> On Mon, 19 Dec 2022 at 07:57, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
>> > G = Decimal( 6.6743015E-11 )
>> > r = Decimal( 6.371E6 )
>> > M = Decimal( 5.9722E24 )
>>
>> What's the point of using Decimal if you start with nothing more than
>> float accuracy?
>
> Right. He also interpreted the notation "6.67430(15)E-11" wrong. The
> digits in parentheses represent the uncertainty in the same number of
> last digits. So "6.67430(15)E-11" means "something between 6.67430E-11 -
> 0.00015E-11 and 6.67430E-11 + 0.00015E-11". The r value has only a
> precision of 1 km and I'm not sure how accurate the mass is. Let's just
> assume (for the sake of the argument) that these are actually accurate in
> all given digits.
>
> So G is between 6.67415E-11 and 6.67445E-11, r is between 6.3705E6 and
> 6.3715E6 and M is between 5.97215E24 and 5.97225E24. If we compute the
> time for those deviations you will find that the differences are many
> orders of magnitude greater than the effect you wanted to show. And that
> still ignores the fact that a vacuum won't be perfect (and collisions
> with a few stray atoms might have a similarly tiny effect), that gravity
> isn't constant while the weight falls (it's getting closer to the center
> of the earth and it's moving past other masses on its way) that Newton's
> law is only an approximation, etc. So while the effect is (almost
> certainly) real, the numbers are garbage.
>
> I think there's a basic numeracy problem here. This is unfortunately all
> too common, even among scientists. The OP apparently rounded their
> numbers to 8 significant digits (thereby introducing an error of about
> 1E-8) and then insisted that the additional error of 1E-15 introduced by
> the decimal to float conversion was unacceptable, showing IMHO a
> fundamental misunderstanding of the numbers they are working with.
>
To be fair, I don't think I've never seen that notation either! I've
only ever seen the form 6.67430E-11 ± 0.00015E-11, which is much clearer.
More information about the Python-list
mailing list