Karim Belabas on Sun, 04 Dec 2022 10:09:03 +0100


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

Re: I don't find the solution ...


* Jean-Luc ARNAUD [2022-12-04 02:03]:
> Hi,
> 
> Working with eval, I get the expected result with:
> 
>     eval([ a=((6*k)!*(-1)^k)/(((3*k)!*(k!)^3)*640320^(3*k)), k*a ]);
> 
> But I don't achieve the same calculation with pareval.
> 
> I'm using ()-> for the first equation, but what should I use for the second?
> 
> I tried:
> 
>     pareval([ (a)->((6*k)!*(-1)^k)/(((3*k)!*(k!)^3)*640320^(3*k)), ()->k*a
> ]));
> 
> or:
> 
>     eval([ ()->a=((6*k)!*(-1)^k)/(((3*k)!*(k!)^3)*640320^(3*k)), ()->k*a
> ]));
> 
> The first pareval results in correct calculation of the first term, but the
> second term is always 0.

Please state what you are really trying to achieve. The above breaks 
fundamental assumptions of PARI's parallel model; see ??eval :
"closures must not access global variales and must be free of side effects".
>From the distribution or PARI website, the booklet 'Introduction to
parallel GP' (esp. section 2.) should be useful as well.

Incidentally, you should replace factorials by binomial coefficients as
much as possible (or recurrences if consecutive values are needed):

? k=10^6;
? (6*k)!/((3*k)!*(k!)^3);
time = 9,638 ms.
? binomial(6*k,3*k)*binomial(3*k,k)*binomial(2*k,k);
time = 366 ms.
? % == %`
%4 = 1

Cheers,

    K.B.
--
Karim Belabas  /  U. Bordeaux,  vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/
`