about summary refs log tree commit diff
path: root/sysdeps/libm-ieee754/s_cacoshf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754/s_cacoshf.c')
-rw-r--r--sysdeps/libm-ieee754/s_cacoshf.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/sysdeps/libm-ieee754/s_cacoshf.c b/sysdeps/libm-ieee754/s_cacoshf.c
index bcfebea123..6aa33e5a48 100644
--- a/sysdeps/libm-ieee754/s_cacoshf.c
+++ b/sysdeps/libm-ieee754/s_cacoshf.c
@@ -21,6 +21,7 @@
 #include <complex.h>
 #include <math.h>
 
+#include "math_private.h"
 
 __complex__ float
 __cacoshf (__complex__ float x)
@@ -66,6 +67,7 @@ __cacoshf (__complex__ float x)
     }
   else
     {
+#if 1
       __complex__ float y;
 
       __real__ y = (__real__ x - __imag__ x) * (__real__ x + __imag__ x) - 1.0;
@@ -77,6 +79,19 @@ __cacoshf (__complex__ float x)
       __imag__ y += __imag__ x;
 
       res = __clogf (y);
+#else
+      float re2 = __real__ x * __real__ x;
+      float im2 = __imag__ x * __imag__ x;
+      float sq = re2 - im2 - 1.0;
+      float ro = __ieee754_sqrtf (sq * sq + 4 * re2 * im2);
+      float a = __ieee754_sqrtf ((sq + ro) / 2.0);
+      float b = __ieee754_sqrtf ((-sq + ro) / 2.0);
+
+      __real__ res = 0.5 * __ieee754_logf (re2 + __real__ x * 2 * a
+					   + im2 + __imag__ x * 2 * b
+					   + ro);
+      __imag__ res = __ieee754_atan2f (__imag__ x + b, __real__ x + a);
+#endif
     }
 
   return res;