Ruud H.G. van Tol on Sat, 26 Nov 2022 13:18:29 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

binomial() challenge (+thanks)



PARI binomial() challenge:

binom_1(n,k) = gamma(n+1) / gamma(k+1) / gamma(n-k+1)
binom_2(n,k) = exp(lngamma(n+1) - lngamma(k+1) - lngamma(n-k+1))

? version()
%12 = [2, 15, 1]

? 1.0* binomial(2^55,43)
%13 = 1.4282133046347667042864235447599552118 E659

? 1.0* binom_1(2^55,43)
%14 = 1.4282133046347667042864235447599552118 E659

? 1.0* binom_2(2^55,43)
%15 = 1.4282133046347667042944763056801257481 E659

and then

? 1.0* binomial(10^40,43)
%16 = 1.6552108677421951886982956337138493958 E1667

? 1.0* binom_2(10^40,43)
%17 = 7.416480782428988905 E1778


Also: with slightly higher-n, the UDFs fail.


So it looks to me, that always using binomial(),
so never even consider using an alternative,
is simply the right way. Thanks for that! :)

-- Ruud