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: f(365,2000) 0.21611945163321847 This works *in Sagemath*. It wouldn’t work in Python : the range of the magnitudes of the terms of the *alternating* sum are way too large for the precision of Python’s floats, necessary if you want to use math.comb. Programming this in Python would need some serious analytical work, or using a multiple-precision integer library, which Sage does for you… [ Re-snip... ] HTH, -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/951d18fd-1e64-4943-bc7d-d653b9035ce4n%40googlegroups.com.