34
34
35
35
/*
36
36
FUNCTION
37
- <<catan>>, <<catanf>>---complex arc tangent
37
+ <<catan>>, <<catanf>>---complex arc tangent
38
38
39
39
INDEX
40
- catan
40
+ catan
41
41
INDEX
42
- catanf
42
+ catanf
43
43
44
44
SYNOPSIS
45
45
#include <complex.h>
@@ -48,37 +48,37 @@ SYNOPSIS
48
48
49
49
50
50
DESCRIPTION
51
- @ifnottex
52
- These functions compute the complex arc tangent of <[z]>,
53
- with branch cuts outside the interval [-i, +i] along the
54
- imaginary axis.
55
- @end ifnottex
56
- @tex
57
- These functions compute the complex arc tangent of <[z]>,
58
- with branch cuts outside the interval [$-i$, $+i$] along the
59
- imaginary axis.
60
- @end tex
61
-
62
- <<catanf>> is identical to <<catan>>, except that it performs
63
- its calculations on <<floats complex>>.
51
+ @ifnottex
52
+ These functions compute the complex arc tangent of <[z]>,
53
+ with branch cuts outside the interval [-i, +i] along the
54
+ imaginary axis.
55
+ @end ifnottex
56
+ @tex
57
+ These functions compute the complex arc tangent of <[z]>,
58
+ with branch cuts outside the interval [$-i$, $+i$] along the
59
+ imaginary axis.
60
+ @end tex
61
+
62
+ <<catanf>> is identical to <<catan>>, except that it performs
63
+ its calculations on <<floats complex>>.
64
64
65
65
RETURNS
66
- @ifnottex
67
- These functions return the complex arc tangent value, in the range
68
- of a strip mathematically unbounded along the imaginary axis
69
- and in the interval [-pi/2, +pi/2] along the real axis.
70
- @end ifnottex
71
- @tex
72
- These functions return the complex arc tangent, in the range
73
- of a strip mathematically unbounded along the imaginary axis
74
- and in the interval [$-\pi/2$, $+\pi/2$] along the real axis.
75
- @end tex
66
+ @ifnottex
67
+ These functions return the complex arc tangent value, in the range
68
+ of a strip mathematically unbounded along the imaginary axis
69
+ and in the interval [-pi/2, +pi/2] along the real axis.
70
+ @end ifnottex
71
+ @tex
72
+ These functions return the complex arc tangent, in the range
73
+ of a strip mathematically unbounded along the imaginary axis
74
+ and in the interval [$-\pi/2$, $+\pi/2$] along the real axis.
75
+ @end tex
76
76
77
77
PORTABILITY
78
- <<catan>> and <<catanf>> are ISO C99
78
+ <<catan>> and <<catanf>> are ISO C99
79
79
80
80
QUICKREF
81
- <<catan>> and <<catanf>> are ISO C99
81
+ <<catan>> and <<catanf>> are ISO C99
82
82
83
83
*/
84
84
@@ -100,8 +100,17 @@ catan(double complex z)
100
100
x = creal (z );
101
101
y = cimag (z );
102
102
103
- if ((x == 0.0 ) && (y > 1.0 ))
104
- goto ovrf ;
103
+ if (x == 0.0 ) {
104
+ if (y > 1.0 ) {
105
+ return CMPLX (M_PI_2 , 0.5 * log ((1.0 + y )/(y - 1.0 )));
106
+ }
107
+ if (y < -1.0 ) {
108
+ return CMPLX (- M_PI_2 , 0.5 * log ((1.0 - y )/(- y - 1.0 )));
109
+ }
110
+ if (fabs (y ) <= 1.0 ) {
111
+ return CMPLX (0.0 , atanh (y ));
112
+ }
113
+ }
105
114
106
115
x2 = x * x ;
107
116
a = 1.0 - x2 - (y * y );
0 commit comments