If you permit a beginner's question here (I found no other mailing list):
With the program below, I am stuck at a precision of some 10^-17. How to enforce given prec, to get the advantages of arbitrary-precision computation?
Thanks, Joachim
---
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <flint/arb.h>
#include <flint/acb.h>
int main(int argc, char *argv[])
{
if (argc != 3) {
fprintf(stderr, "Usage: %s <x> <y>\n", argv[0]);
return 1;
}
char *endptr;
double x = strtod(argv[1], &endptr);
assert(*endptr == '\0');
double y = strtod(argv[2], &endptr);
assert(*endptr == '\0');
printf("Called with args %g %g\n", x, y);
acb_t Z;
acb_init(Z);
arb_set_d(acb_realref(Z), x);
arb_set_d(acb_realref(Z), y);
acb_t W;
acb_init(W);
for (short prec = 1<<2; prec < 1<<10; prec *= 2) {
acb_sqrt(W, Z, prec);
printf("Using %5ld bits, erfc(z) = ", prec);
acb_printn(W, 16, 0); printf("\n");
}
acb_clear(Z); acb_clear(W);
return 0;
}
Output:
Called with args 2 0.37
Using 4 bits, erfc(z) = [+/- 0.626]
Using 8 bits, erfc(z) = [0.61 +/- 8.44e-3]
Using 16 bits, erfc(z) = [0.6083 +/- 5.42e-5]
Using 32 bits, erfc(z) = [0.608276253 +/- 3.66e-10]
Using 64 bits, erfc(z) = [0.6082762530298220 +/- 3.49e-17]
Using 128 bits, erfc(z) = [0.6082762530298220 +/- 3.48e-17]
Using 256 bits, erfc(z) = [0.6082762530298220 +/- 3.48e-17]
Using 512 bits, erfc(z) = [0.6082762530298220 +/- 3.48e-17]