+static ex atan_series(const ex &x,
+ const relational &rel,
+ int order,
+ unsigned options)
+{
+ GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
+ // method:
+ // Taylor series where there is no pole or cut falls back to atan_deriv.
+ // There are two branch cuts, one runnig from I up the imaginary axis and
+ // one running from -I down the imaginary axis. The points I and -I are
+ // poles.
+ // On the branch cuts and the poles series expand
+ // log((1+I*x)/(1-I*x))/(2*I)
+ // instead.
+ // (The constant term on the cut itself could be made simpler.)
+ const ex x_pt = x.subs(rel);
+ if (!(I*x_pt).info(info_flags::real))
+ throw do_taylor(); // Re(x) != 0
+ if ((I*x_pt).info(info_flags::real) && abs(I*x_pt)<_ex1())
+ throw do_taylor(); // Re(x) == 0, but abs(x)<1
+ // if we got here we have to care for cuts and poles
+ return (log((1+I*x)/(1-I*x))/(2*I)).series(rel, order, options);
+}
+