5 extern double f__cabs (double, double);
7 z_log (doublecomplex
* r
, doublecomplex
* z
)
9 double s
, s0
, t
, t2
, u
, v
;
10 double zi
= z
->i
, zr
= z
->r
;
12 r
->i
= atan2 (zi
, zr
);
14 r
->r
= log (f__cabs (zr
, zi
));
27 s
= zr
* sqrt (1 + t
* t
);
28 /* now s = f__cabs(zi,zr), and zr = |zr| >= |zi| = zi */
38 log (1 + x
) = x
- x
^ 2 / 2 + x
^ 3 / 3 - x
^ 4 / 4 + -...
39 = x (1 - x
/ 2 + x
^ 2 / 3 - +...)
40 [sqrt (y
^ 2 + z
^ 2) - 1] *[sqrt (y
^ 2 + z
^ 2) + 1] =
41 y
^ 2 + z
^ 2 - 1, so
sqrt (y
^ 2 + z
^ 2) - 1 =
42 (y
^ 2 + z
^ 2 - 1) /[sqrt (y
^ 2 + z
^ 2) + 1]
44 t
= ((zr
* zr
- 1.) + zi
* zi
) / (s
+ 1);
53 s
+= u
/ v
- t
* u
/ (v
+ 1);