- // if we got here we have to care for cuts and poles
- return (log((1+x)/(1-x))/2).series(rel, order, options);
+ // care for the poles, using the defining formula for atanh()...
+ if (arg_pt.is_equal(_ex1()) || arg_pt.is_equal(_ex_1()))
+ return ((log(_ex1()+arg)-log(_ex1()-arg))*_ex1_2()).series(rel, order, options);
+ // ...and the branch cuts (the discontinuity at the cut being just I*Pi)
+ if (!(options & series_options::suppress_branchcut)) {
+ // method:
+ // This is the branch cut: assemble the primitive series manually and
+ // then add the corresponding complex step function.
+ const symbol *s = static_cast<symbol *>(rel.lhs().bp);
+ const ex point = rel.rhs();
+ const symbol foo;
+ ex replarg = series(atanh(arg), *s==foo, order).subs(foo==point);
+ ex Order0correction = replarg.op(0)+csgn(I*arg)*Pi*I*_ex1_2();
+ if (arg_pt<_ex0())
+ Order0correction += log((arg_pt+_ex_1())/(arg_pt+_ex1()))*_ex1_2();
+ else
+ Order0correction += log((arg_pt+_ex1())/(arg_pt+_ex_1()))*_ex_1_2();
+ epvector seq;
+ seq.push_back(expair(Order0correction, _ex0()));
+ seq.push_back(expair(Order(_ex1()), order));
+ return series(replarg - pseries(rel, seq), rel, order);
+ }
+ throw do_taylor();