7 #include "cl_complex.h"
16 // Wert und Branch Cuts nach der Formel CLTL2, S. 315:
17 // artanh(z) = (log(1+z)-log(1-z)) / 2
18 // Sei z=x+iy, Ergebnis u+iv.
19 // Falls x=0 und y=0: u=0, v=0.
20 // Falls x=0: u = 0, v = atan(X=1,Y=y).
22 // x rational -> x in Float umwandeln.
23 // |x|<1/2: u = atanh(x), v = 0.
24 // |x|>=1/2: (1+x)/(1-x) errechnen,
26 // >0 (also |x|<1) -> u = 1/2 log((1+x)/(1-x)), v = 0.
27 // <0 (also |x|>1) -> u = 1/2 log(-(1+x)/(1-x)),
28 // v = (-pi/2 für x>1, pi/2 für x<-1).
30 // 1+x und 1-x errechnen.
31 // x und y in Floats umwandeln.
32 // |4x| und 1+x^2+y^2 errechnen,
33 // |4x| < 1+x^2+y^2 -> u = 1/2 atanh(2x/(1+x^2+y^2)),
34 // |4x| >= 1+x^2+y^2 -> u = 1/4 ln ((1+x^2+y^2)+2x)/((1+x^2+y^2)-2x)
35 // oder besser (an der Singularität: |x|-1,|y| klein):
36 // u = 1/4 ln ((1+x)^2+y^2)/((1-x)^2+y^2).
37 // v = 1/2 atan(X=(1-x)(1+x)-y^2,Y=2y) * (-1 falls Y=0.0 und X<0.0 und x>=0.0,
39 // Ergebnis ist reell nur, wenn z reell.
40 // Real- und Imaginärteil des Ergebnisses sind Floats, außer wenn z reell oder
43 inline const cl_C_R _atanh (const cl_N& z)
50 return atanh(realpart(z),imagpart(z));
54 const cl_N atanh (const cl_N& z)
56 var cl_C_R u_v = _atanh(z);
57 var cl_R& u = u_v.realpart;
58 var cl_R& v = u_v.imagpart;