ex-2/fanc{y, ier}: use stricter number of terms

This commit is contained in:
Michele Guerini Rocco 2020-05-25 23:30:33 +00:00
parent 6ccaff5bbd
commit f6111967de
2 changed files with 6 additions and 4 deletions

View File

@ -432,7 +432,8 @@ void a_series(mpq_t rop, size_t N) {
mpz_set_ui(fact, 1);
mpz_set_ui(power, 1);
for (size_t k = 0; k < 5*N; k++) {
size_t kmax = 4.97 * N;
for (size_t k = 0; k <= kmax; k++) {
if (k > 0) {
mpz_mul_ui(fact, fact, k);
mpz_mul(power, power, stop);
@ -469,7 +470,8 @@ void b_series(mpq_t rop, size_t N){
mpz_set_ui(fact, 1);
mpz_set_ui(power, 1);
for (size_t k = 0; k < 5*N; k++) {
size_t kmax = 4.97 * N;
for (size_t k = 0; k <= kmax; k++) {
if (k > 0) {
mpz_mul_ui(fact, fact, k);
mpz_mul(power, power, stop);

View File

@ -146,10 +146,10 @@ void mpf_gamma(mpf_t rop, size_t digits) {
* ignoring the C/B² term, to less than 10^-D is α2^p where α
* is the solution of:
*
* α log(α) = 3 + α α = exp(W(3e) - 1) 4.97
* α log(α) = 1 + α α = exp(W(3e) - 1) 4.97
*
*/
size_t kmax = 4.97 * (1 << p);
size_t kmax = 3.59 * (1 << p);
fprintf(stderr, "[mpf_gamma] iterations: %ld\n", kmax);
// initialise variables