Re: [sage-support] Issues with real precision

2024-02-24 Thread Emmanuel Charpentier
Le samedi 24 février 2024 à 18:11:25 UTC+1, Gareth Ma a écrit : Note that you can wrap it in `Decimal` or `Fraction`, which are both builtin Python libraries. I stand corrected. Python ints are bignums, *not* 32-bits integers. and fractions.Fractions are rationals. Ordinary integer arithmetic

Re: [sage-support] Issues with real precision

2024-02-24 Thread Gareth Ma
Note that you can wrap it in `Decimal` or `Fraction`, which are both builtin Python libraries. On Saturday 24 February 2024 at 13:54:51 UTC Emmanuel Charpentier wrote: > Le vendredi 23 février 2024 à 23:23:20 UTC+1, Dima Pasechnik a écrit : > > [ Snip…] > > the normal Python way, without any sym

Re: [sage-support] Issues with real precision

2024-02-24 Thread Emmanuel Charpentier
Le vendredi 23 février 2024 à 23:23:20 UTC+1, Dima Pasechnik a écrit : [ Snip…] the normal Python way, without any symbolic sum, would be like this: sage: sage: g(n,k,r)=(-1)^(k)*binomial(n,k)*(n-k)^r/n^r : sage: def f(n,r): return math.fsum([1.0*g(n,k,r) for k in range(n+1)]) : sage:

Re: [sage-support] Issues with real precision

2024-02-23 Thread Dima Pasechnik
On Friday, February 23, 2024 at 10:16:37 PM UTC dim...@gmail.com wrote: On Fri, Feb 23, 2024 at 05:00:42PM -0500, Fernando Gouvea wrote: > In an introductory probability class, one computes the probability of > getting all of n possible coupons in r individual purchases. The naive > approach

Re: [sage-support] Issues with real precision

2024-02-23 Thread dimpase
On Fri, Feb 23, 2024 at 05:00:42PM -0500, Fernando Gouvea wrote: > In an introductory probability class, one computes the probability of > getting all of n possible coupons in r individual purchases. The naive > approach with inclusion-exclusion leads to the awful formula > > f(n,r) = \sum_{k=0}