I need help for parallel optimization

Jean-Luc Arnaud <[email protected]>
Newsgroups gmane.comp.mathematics.pari.user
Message-ID <[email protected]>
Hi all,

I've coded a GP Script calculating Pi digits based en Chudnovski algorithm.

It works very well and fast (≈ 1 min 43 s for 1 000 000 digits) but I'd 
like to optimize it with parallel calculation.

I tried parsum, pareval, vecsum with parapply, all these tests work very 
fast but results are false after the 13th digit.

Would anyone be so kind as to modify my script in order to use parallel 
calculation with exact result?

In addition any explanation about this parallel script be highly 
appreciated.

Thanks a lot

Jean-Luc

===============================

addhelp(ChudnovskyNew,"ChudnovskyNew(n, print_flag) recherche les n 
décimales de Pi par l'algorithme de Chudnovsky. print_flag = 1 -> 
impression du résultat.")

/*

// a_k = a_k * (-(6*n-5)*(2*n-1)*(6*n-1))
// n^3 / C3_OVER_24
// a_k = a_k / n^3 / C3_OVER_24
// a_sum = a_sum + a_k
// b_sum = b_sum + n * a_k
// Total = 13591409*a_sum + 545140134*b_sum then Pi = 
(426880*fpSqrt(10005)) / total

*/

ChudnovskyNew(n, print_flag) =
{default(realprecision,n+2); /* Précision fixée au nombre de décimales+1 */
my(
a_k=1.0,
a_sum=1.,
b_sum=0.,
iter=(n+2)/14.1816474627254776555,
C=640320,
C3=C^3/24
);

/* Compute values with Formule de Chudnovsky */

for(i=1, iter,
     a_k = a_k*(-(6*i-5)*(2*i-1)*(6*i-1)) / i^3 / C3;
     a_sum = a_sum + a_k; b_sum = b_sum + i*a_k
     );

   myPi = (426880*sqrt(10005))/(13591409 * a_sum + 545140134 * b_sum);

   if (print_flag==1, print(n," premières décimales de Pi: ",myPi))

};
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.