ex-2/fanc{y, ier}: use stricter number of terms
This commit is contained in:
parent
6ccaff5bbd
commit
f6111967de
@ -432,7 +432,8 @@ void a_series(mpq_t rop, size_t N) {
|
|||||||
|
|
||||||
mpz_set_ui(fact, 1);
|
mpz_set_ui(fact, 1);
|
||||||
mpz_set_ui(power, 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) {
|
if (k > 0) {
|
||||||
mpz_mul_ui(fact, fact, k);
|
mpz_mul_ui(fact, fact, k);
|
||||||
mpz_mul(power, power, stop);
|
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(fact, 1);
|
||||||
mpz_set_ui(power, 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) {
|
if (k > 0) {
|
||||||
mpz_mul_ui(fact, fact, k);
|
mpz_mul_ui(fact, fact, k);
|
||||||
mpz_mul(power, power, stop);
|
mpz_mul(power, power, stop);
|
||||||
|
@ -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 α
|
* ignoring the C/B² term, to less than 10^-D is α⋅2^p where α
|
||||||
* is the solution of:
|
* 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);
|
fprintf(stderr, "[mpf_gamma] iterations: %ld\n", kmax);
|
||||||
|
|
||||||
// initialise variables
|
// initialise variables
|
||||||
|
Loading…
Reference in New Issue
Block a user