about summary refs log tree commit diff
path: root/math/k_casinhf.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-03-30 13:31:53 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-03-30 13:31:53 +0000
commitccc8cadf750fc3626fa418a92642b6127428f404 (patch)
tree51befecaa48f28eed844c0aba00913fb5c504f6f /math/k_casinhf.c
parent0d1029de128ad2afd4a7b13a0805aea8fdb82e37 (diff)
downloadglibc-ccc8cadf750fc3626fa418a92642b6127428f404.tar.gz
glibc-ccc8cadf750fc3626fa418a92642b6127428f404.tar.xz
glibc-ccc8cadf750fc3626fa418a92642b6127428f404.zip
Fix casinh inaccuracy for imaginary part < 1.0, real part small (bug 10357).
Diffstat (limited to 'math/k_casinhf.c')
-rw-r--r--math/k_casinhf.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/math/k_casinhf.c b/math/k_casinhf.c
index b368313390..56565e25e2 100644
--- a/math/k_casinhf.c
+++ b/math/k_casinhf.c
@@ -136,6 +136,58 @@ __kernel_casinhf (__complex__ float x, int adj)
 	    __imag__ res = __ieee754_atan2f (1.0f + s2, rx + s1);
 	}
     }
+  else if (ix < 1.0f && rx < 0.5f)
+    {
+      if (ix >= FLT_EPSILON)
+	{
+	  if (rx < FLT_EPSILON * FLT_EPSILON)
+	    {
+	      float onemix2 = (1.0f + ix) * (1.0f - ix);
+	      float s = __ieee754_sqrtf (onemix2);
+
+	      __real__ res = __log1pf (2.0f * rx / s) / 2.0f;
+	      if (adj)
+		__imag__ res = __ieee754_atan2f (s, __imag__ x);
+	      else
+		__imag__ res = __ieee754_atan2f (ix, s);
+	    }
+	  else
+	    {
+	      float onemix2 = (1.0f + ix) * (1.0f - ix);
+	      float rx2 = rx * rx;
+	      float f = rx2 * (2.0f + rx2 + 2.0f * ix * ix);
+	      float d = __ieee754_sqrtf (onemix2 * onemix2 + f);
+	      float dp = d + onemix2;
+	      float dm = f / dp;
+	      float r1 = __ieee754_sqrtf ((dp + rx2) / 2.0f);
+	      float r2 = rx * ix / r1;
+
+	      __real__ res
+		= __log1pf (rx2 + dm + 2.0f * (rx * r1 + ix * r2)) / 2.0f;
+	      if (adj)
+		__imag__ res = __ieee754_atan2f (rx + r1,
+						 __copysignf (ix + r2,
+							      __imag__ x));
+	      else
+		__imag__ res = __ieee754_atan2f (ix + r2, rx + r1);
+	    }
+	}
+      else
+	{
+	  float s = __ieee754_hypotf (1.0f, rx);
+
+	  __real__ res = __log1pf (2.0f * rx * (rx + s)) / 2.0f;
+	  if (adj)
+	    __imag__ res = __ieee754_atan2f (s, __imag__ x);
+	  else
+	    __imag__ res = __ieee754_atan2f (ix, s);
+	}
+      if (__real__ res < FLT_MIN)
+	{
+	  volatile float force_underflow = __real__ res * __real__ res;
+	  (void) force_underflow;
+	}
+    }
   else
     {
       __real__ y = (rx - ix) * (rx + ix) + 1.0f;