summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2008-11-17 09:09:37 +0000
committerzimmerma <zimmerma@211d60ee-9f03-0410-a15a-8952a2c7a4e4>2008-11-17 09:09:37 +0000
commit89255240a4c2ad3e6daea7925d47ec56c421ca30 (patch)
tree37b8cb30c9ddd4b42e65b0c1edb2c79081ab6059
parent7bb56b1b8b6ea661a9462ce57ee1b59d3a11c174 (diff)
downloadmpc-89255240a4c2ad3e6daea7925d47ec56c421ca30.tar.gz
[tan.dat] added one more corner case, which should give a 100% coverage
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@319 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r--src/tan.c11
-rw-r--r--tests/tan.dat3
2 files changed, 9 insertions, 5 deletions
diff --git a/src/tan.c b/src/tan.c
index 8538391..45571c9 100644
--- a/src/tan.c
+++ b/src/tan.c
@@ -206,16 +206,17 @@ mpc_tan (mpc_ptr rop, mpc_srcptr op, mpc_rnd_t rnd)
/* some parts of the quotient may be exact */
inex = mpc_div (x, x, y, MPC_RNDZZ);
- /* OP is no pure real nor pure imaginary, so the real and imaginary
- parts of its tangent cannot be null. */
- /* This part of code is apparently never reached; AE */
-#if 1 /* PZ: I agree, but until we prove it is never reached, let's keep it. */
+ /* OP is no pure real nor pure imaginary, so in theory the real and
+ imaginary parts of its tangent cannot be null. However due to
+ rouding errors this might happen. Consider for example
+ tan(1+14*I) = 1.26e-10 + 1.00*I. For small precision sin(op) and
+ cos(op) differ only by a factor I, thus after mpc_div x = I and
+ its real part is zero. */
if (mpfr_zero_p (MPC_RE (x)) || mpfr_zero_p (MPC_IM (x)))
{
err = prec; /* double precision */
continue;
}
-#endif
if (MPC_INEX_RE (inex))
mpfr_signbit (MPC_RE (x)) ?
mpfr_nextbelow (MPC_RE (x)) : mpfr_nextabove (MPC_RE (x));
diff --git a/tests/tan.dat b/tests/tan.dat
index 30b9f8a..dfc93ca 100644
--- a/tests/tan.dat
+++ b/tests/tan.dat
@@ -121,3 +121,6 @@
# yet another absurd case: op = atan (2^200) + 2^(-200000)*I;
# expensive to compute
# 50 0x1@50 50 0x1@-49900 1000 0x1.921fb54442d18469898cc51701b839a252049c1114cf98e803177d4c76273644a29410f31c6809bbdf2a33679a748636605614dbe4be286e9fc26adadaa3848bc90b6aecc4bcfd8de8988628a1c5302b6d540ec33d62c53131c62d4c0a6894a0b2939d784deb9521e7a621f92f1e0bd0d9564ec6981cd3608709e5c18e 1000 0x1@-50000 N N
+
+# corner case
+9 -0x9bp-51 9 -1 9 -0x16dp-8 9 -0x77p-3 N N