/* $Id: pb-trig-dir.c 47490 2011-11-10 17:07:08Z vinc17/ypig $ */ #include #include #include #include static const mp_rnd_t rnd[3] = { MPFR_RNDD, MPFR_RNDN, MPFR_RNDU }; int main (int argc, char *argv[]) { mpfr_t x, s, c; int prec, i; if (argc != 3) { fprintf (stderr, "Usage: pb-trig-dir \n"); exit (EXIT_FAILURE); } prec = atoi (argv[2]); if (prec < MPFR_PREC_MIN || prec > MPFR_PREC_MAX) { fprintf (stderr, "pb-trig-dir: incorrect precision %d\n", prec); exit (EXIT_FAILURE); } mpfr_inits2 (prec, x, s, c, (void *) 0); if (mpfr_set_str (x, argv[1], 0, MPFR_RNDN)) { fprintf (stderr, "pb-trig-dir: bad value x (%s)\n", argv[1]); exit (EXIT_FAILURE); } printf ("Lower bound, value using MPFR_RNDN, upper bound:\n"); for (i = 0; i < 3; i++) { mpfr_sin_cos (s, c, x, rnd[i]); mpfr_hypot (x, s, c, rnd[i]); mpfr_out_str (stdout, 10, 0, x, rnd[i]); putchar ('\n'); } mpfr_clears (x, s, c, (void *) 0); return 0; } /* The result seems to be always exactly 1. Try x >= 1e200000 to see the slow down (only for the first rounding mode, because of cached pi). */