Precision Tail-off?

Peter Pearson pkpearson at nowhere.invalid
Thu Feb 16 10:40:19 EST 2023


On Tue, 14 Feb 2023 11:17:20 +0000, Oscar Benjamin wrote:
> On Tue, 14 Feb 2023 at 07:12, Stephen Tucker <stephen_tucker at sil.org> wrote:
[snip]
>> I have just produced the following log in IDLE (admittedly, in Python
>> 2.7.10 and, yes I know that it has been superseded).
>>
>> It appears to show a precision tail-off as the supplied float gets bigger.
[snip]
>>
>> For your information, the first 20 significant figures of the cube root in
>> question are:
>>    49793385921817447440
>>
>> Stephen Tucker.
>> ----------------------------------------------
>> >>> 123.456789 ** (1.0 / 3.0)
>> 4.979338592181744
>> >>> 123456789000000000000000000000000000000000. ** (1.0 / 3.0)
>> 49793385921817.36
>
> You need to be aware that 1.0/3.0 is a float that is not exactly equal
> to 1/3 ...
[snip]
> SymPy again:
>
> In [37]: a, x = symbols('a, x')
>
> In [38]: print(series(a**x, x, Rational(1, 3), 2))
> a**(1/3) + a**(1/3)*(x - 1/3)*log(a) + O((x - 1/3)**2, (x, 1/3))
>
> You can see that the leading relative error term from x being not
> quite equal to 1/3 is proportional to the log of the base. You should
> expect this difference to grow approximately linearly as you keep
> adding more zeros in the base.

Marvelous.  Thank you.


-- 
To email me, substitute nowhere->runbox, invalid->com.


More information about the Python-list mailing list