ex-2/fancier: optimise out an operation
This commit is contained in:
parent
f73c9b14b3
commit
845548fa93
@ -340,20 +340,17 @@ void mpq_log_ui(mpq_t rop, size_t x, size_t digits) {
|
||||
mpq_div(low, term, temp);
|
||||
mpq_add(low, sum, low);
|
||||
|
||||
/* Average the two bounds */
|
||||
/* Average the two bounds
|
||||
* Note: we don't divive the sum by 2 because we
|
||||
* actually need 2 Σ_{k=0} y^(2k+1)/(2k+1).
|
||||
*/
|
||||
mpq_add(sum, low, upp);
|
||||
mpz_div_ui(mpq_numref(sum), mpq_numref(sum), 2);
|
||||
mpq_canonicalize(sum);
|
||||
|
||||
size_t d = digits > 50 ? 50 : digits;
|
||||
mpq_fprintf(stderr, d+2, "[mpq_log_ui] upper bound: %q...\n", upp);
|
||||
mpq_fprintf(stderr, d+2, "[mpq_log_ui] lower bound: %q...\n", low);
|
||||
mpq_fprintf(stderr, d, "[mpq_log_ui] series: %q...\n", sum);
|
||||
|
||||
// multiply by 2
|
||||
mpz_mul_ui(mpq_numref(sum), mpq_numref(sum), 2);
|
||||
mpq_canonicalize(sum);
|
||||
|
||||
// calculate log(2)*(m-1)
|
||||
mpq_t log2; mpq_init(log2);
|
||||
mpq_log2(log2, digits);
|
||||
|
Loading…
Reference in New Issue
Block a user